github / github/copilot-cli

Custom agent support for 'skills' field to limit which skills are preloaded into context

未关闭
#3,940 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:agents area:plugins
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

### Describe the feature or problem you'd like to solve

Ability to define 'skills' field in a custom agent to limit which skills are preloaded into context

### Proposed solution

If I create a custom agent `.github/agents/dotnet-developer.md`

```
---
name: dotnet-developer
description: A .NET/C# developer agent focused on writing, refactoring, and debugging dotnet code.
model: claude-sonnet-4.6
tools: []
skills: []
---

You are a senior .NET developer specializing in C# and the dotnet ecosystem.

## Responsibilities
- Write clean, idiomatic, and maintainable C# code following modern .NET conventions.
- Use appropriate dotnet CLI commands (`dotnet build`, `dotnet test`, `dotnet run`) to build, test, and run projects.
- Refactor and debug existing C# code, diagnosing and fixing issues precisely.
- Follow the project's existing patterns, style, and architecture.

## Guidelines
- Prefer the latest stable language features and framework APIs unless the project targets an older version.
- Validate changes by building and running the relevant tests before considering work complete.
- Make surgical, focused changes; do not modify unrelated code.
- Add comments only where the intent is not obvious from the code itself.

## Constraints
- You do not have access to MCP servers.
- Rely on the tools listed above to complete tasks.

```

and select the agent via CLI with `copilot --agent="dotnet-developer"`

I would expect:
1. Agent only has access to tools listed in `tools`, in this case, no tools should be available. This works ✅ Asking agent to use a tool it does not have access to fails (even though the agent might think it has access to it due to custom agent description).
2. Agent only has preloaded skills listed in 'skills': in this case, all tools are available, as can be seen by running `/skills` while inside of the agent. This can also by testing by asking the agent to use a skill which it should not have access to - it succeeds, even though `skills` tool is not listed in `tools` either

It is not expected that
1. Agent has access to `skill` tool when the `skill` tool is not listed in `tools: []`
2. `skills` field of the custom agent definition is ignored and all skills are discoverable by the agent when `skill` tool is not allowed

For example, adding a skill `.github/skills/tell-a-joke/SKILL.md`:

```
---
name: tell-a-joke
description: Tell the user a joke. Use when the user asks for a joke, says "make me laugh", "tell me something funny", "cheer me up", or invokes /tell-a-joke. Optionally accepts a topic or category as an argument.
version: 1.0.0
---

# Tell a Joke

Tell the user a joke. If `$ARGUMENTS` is provided, make the joke about that topic. Otherwise, pick one from the fallback list using `dayOfYear % 16` as the index.

## Instructions

1. If a topic was given (`$ARGUMENTS`), craft or recall a joke on that topic.
2. If no topic, pick from the list below.
3. Deliver setup and punchline cleanly — no preamble like "Here's a joke:".
4. Add a single short self-aware remark after the punchline (optional).

## Fallback joke list

0. Why do programmers prefer dark mode? Because light attracts bugs.
1. A SQL query walks into a bar and asks two tables: "Can I join you?"
2. Why do Java developers wear glasses? Because they don't C#.
3. What's a programmer's favourite hangout? The Foo Bar.
4. How do you comfort a JavaScript bug? You console it.
5. Why did the developer go broke? They used up all their cache.
6. Why don't programmers like the outdoors? The sun causes too many reflection issues.
7. Why did the programmer quit? They didn't get arrays.
8. Debugging: being the detective in a crime movie where you're also the murderer.
9. It works on my machine. Ship my machine.
10. There are only 10 types of people: those who understand binary, and those who don't.
11. Knock knock. Who's there? Recursion. Recursion who? Knock knock.
12. A regex walked into a bar. The bartender said "You look like you have a problem." The regex replied: `^You could say that\.$`
13. Why was the function sad after a breakup? Too many arguments.
14. Real programmers count from 0.
15. What do you call a programmer who never comments their code? A job security specialist.

## Tone

Dry, self-aware, light. One joke only — no lists, no follow-ups unless asked.

```
1. copilot --agent="dotnet-developer"
2. `tell a joke`
3. Agent responds with:
```
◐ The user wants to hear a joke. I should invoke the tell-a-joke skill.

● skill(tell-a-joke)

● Why do Java developers wear glasses? Because they don't C#.

Ophthalmology and language wars, all in one.
```

### Example prompts or workflows

Users who have many tools and skills available by default could use agents to delimit tools and skills available for specific role oriented workflows (planning, development, debugging, review) without all tools and skills being preloaded every time, which causes bloated context window, slower models and distracting model from doing it's role oriented job.

`.github/agents/dotnet-developer.md`
```
---
name: dotnet-developer
description: A .NET/C# developer agent focused on writing, refactoring, and debugging dotnet code.
model: claude-sonnet-4.6
tools: []
skills: ["tell-a-joke"]
---
```

Run `copilot --agent="dotnet-developer"` (skills field is defined in the custom agent md file)

`copilot --allow-skills="tell-a-joke"` (override skills available to an agent)
`copilot --allow-skills-add="tell-a-joke"` (append)
`copilot --allow-skills-remove="tell-a-joke"` (uses custom agent with skill field, but removes a specific skill for testing purposes)

Claude seems to have a much wider support for [custom agent definitions](https://code.claude.com/docs/en/sub-agents#supported-frontmatter-fields)

### Additional context

_No response_

贡献指南

打开贡献指南

调研方向

使用 .github/agents/dotnet-developer.md 和示例 .github/skills/tell-a-joke/SKILL.md,通过 copilot --agent="dotnet-developer" 和 /skills 命令复现该行为。跟踪自定义 agent 的 skills 字段和 --allow-skills 选项如何影响预加载和发现。完成标准是 agent 仅公开已配置的 skills,同时工具仍由 tools: [] 控制。

由索引模型根据 Issue 内容生成。

评估

技术栈
github, shell
领域
ai, cli, developer-experience
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。