copilot-sdk-gpt55
Skill10 starsChanged 5 months agoMITView on GitHub
Reflects the actual agent-framework[github-copilot] 1.3.x API installed in this repo. Earlier GitHubCopilotChatClient / ChatAgent(client=...) syntax is not valid here. _RunnableAgent is a @dataclass(frozen=True) adapter exposing async def run(self, message: str) -> AgentResponse[None]. The shared make_app calls .run(req.goal) on it. The Copilot SDK runs every tool call through a permission gate. The handler must return PermissionDecisionApproveOnce(). Without a handler, every call returns: Permission denied and could not request permission from user This bug is silent — the LLM faithfully reports "all…
- Reads credentials
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- a2a-loopback-testsSkill
- aca-bicepSkill
- aks-helmSkill
- maf-agent-skeletonSkill
- mcp-server-skeletonSkill
- pydantic-contractsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 124
If a generated file contains any of these, reject it.
- Very specific: line 128
Every agent.run.* log line must bind:
- Very specific: line 134
Use structlog.contextvars.bind_contextvars(...) in the FastAPI request scope (the shared make_app does this for you).
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: GitHub Copilot SDK on gpt-5.5
Reflects the actual
agent-framework[github-copilot]1.3.x API installed in this repo. EarlierGitHubCopilotChatClient/ChatAgent(client=...)syntax is not valid here.
The two imports
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
from copilot.generated.rpc import PermissionDecisionApproveOnce
from copilot.session import PermissionRequestResult
from src.shared.copilot import build_copilot_clientThe one builder shape
def _approve_all(_request: object, _context: dict[str, str]) -> PermissionRequestResult:
return PermissionDecisionApproveOnce()
async def build_agent(settings: Settings) -> _RunnableAgent:
agent = GitHubCopilotAgent(
instructions=SYSTEM_PROMPT,
client=build_copilot_client(),
name="<name>",
description="...",
tools=list(TOOLS), # local @tool functions, NEVER MCP
default_options=GitHubCopilotOptions(
model=settings.copilot_model, # default "gpt-5.5"
timeout=settings.copilot_timeout_seconds,
on_permission_request=_approve_all, # MANDATORY — see §Permissions
mcp_servers={ # specialists only; orchestrator omits this
"<key>": {
"type": "http",
"url": settings.<which>_mcp_url,
"tools": ["*"],
"timeout": int(settings.copilot_timeout_seconds * 1000),
},
},
),
)
return _RunnableAgent(agent=agent)_RunnableAgent is a @dataclass(frozen=True) adapter exposing async def run(self, message: str) -> AgentResponse[None]. The shared make_app calls .run(req.goal) on it.
Permissions (do NOT skip)
The Copilot SDK runs every tool call through a permission gate. The handler must return PermissionDecisionApproveOnce(). Without a handler, every call returns:
Permission denied and could not request permission from user
This bug is silent — the LLM faithfully reports "all specialists rejected the request" with zero stack trace. Always wire on_permission_request=_approve_all for both MCP tools (specialists) and @tool function tools (orchestrator).
Tool signatures — flat scalars, not Pydantic
The SDK injects tool arguments as a raw dict and does not marshal them into Pydantic models. A signature like async def ask_inventory(req: _AskRequest) raises 'dict' object has no attribute 'goal' at call time.
✅ Correct:
@tool(name="ask_inventory", description="...")
async def ask_inventory(goal: str) -> str:
"""...Args: goal: ... Returns: ..."""❌ Wrong:
@tool(...)
async def ask_inventory(req: _AskRequest) -> str: ...Pydantic models stay valid for models.py (process-boundary types) and FastMCP @mcp.tool() (the MCP server itself does marshal).
MCP wiring
MCP is configured inside GitHubCopilotOptions(mcp_servers={...}), not via the legacy MCPStreamableHTTPTool class. If a generated file imports MCPStreamableHTTPTool, reject it. Specialist tools.py should expose an empty TOOLS: list[FunctionTool] = [] — every external call is an MCP tool.
Authentication
- Local dev: fine-grained PAT in
GITHUB_TOKEN.build_copilot_client()passes it explicitly toCopilotClient(github_token=..., use_logged_in_user=False).docker-compose.ymlfails fast (${GITHUB_TOKEN:?...}) if it's not exported — required even fordocker compose ps/down. - AKS: Key Vault → Secrets Store CSI →
GITHUB_TOKENenv. Pod SA is federated to a UAMI (Workload Identity). - ACA: Key Vault
secretref→GITHUB_TOKEN. Container app uses a UAMI.
Timeouts (hard rules)
Three separate timeouts must all be sized for chained tool calls:
| Knob | Where | Min value | Reason |
GitHubCopilotOptions.timeout | per-agent | 120 s | Orchestrator may chain 4 sequential ask_* tool calls (10–25 s each). 30 s is too tight and surfaces as Timeout after 30.0s waiting for session.idle. |
mcp_servers[*].timeout | specialist agents | int(seconds * 1000) | The Copilot SDK's MCPHTTPServerConfig.timeout is milliseconds, not seconds. |
A2AClient httpx timeout | orchestrator | connect=10, read=120, write=30, pool=10 | An A2A POST /invoke waits on the peer's full LLM run. 30 s read surfaces as httpx.ReadTimeout. |
The lab default is ZAVA_COPILOT_TIMEOUT_SECONDS=120 (set in docker-compose.yml::x-agent-env).
Container runtime gotcha
The Copilot SDK extracts its bundled Node CLI into $HOME/.cache on first call. A non-root container whose HOME defaults to /app (root-owned) fails with:
Failed to extract bundled package: Error: EACCES: permission denied, mkdir '/app/.cache'Fix in the runtime stage of src/Dockerfile.base:
ENV HOME=/home/zava XDG_CACHE_HOME=/home/zava/.cache
RUN useradd --uid 10001 --home /home/zava ... \
&& mkdir -p /home/zava/.cache /app \
&& chown -R 10001:10001 /home/zava /appForbidden in this repo
| ❌ Do not import | Reason |
GitHubCopilotChatClient | Does not exist in agent-framework 1.3.x — only GitHubCopilotAgent |
ChatAgent(client=GitHubCopilotChatClient(...)) | Old API |
MCPStreamableHTTPTool | MCP is wired via GitHubCopilotOptions(mcp_servers=...) |
OpenAIChatClient, AzureOpenAIChatClient | Repo is Copilot-only |
Anything reading OPENAI_API_KEY | Same |
If a generated file contains any of these, reject it.
Logging fields
Every agent.run.* log line must bind:
agent.nameagent.run_idagent.span_id
Use structlog.contextvars.bind_contextvars(...) in the FastAPI request scope (the shared make_app does this for you).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

