Add per-sub-agent timeout / token budget / cancellation API
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 38/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- node.js, typescript
- 领域
- api
调研方向
从 issue 中描述的 CustomAgentConfig 和 Session API 开始,检查现有的 session.abort()、session.disconnect() 以及 subagent.started/subagent.completed 入口点。定义每个 agent 的预算、预算超出事件和定向取消应如何运行,然后验证可以停止一个子代理而不会断开 session。
由索引模型根据 Issue 内容生成。
描述
Summary
Consumers running multi-sub-agent sessions have no way to bound an individual sub-agent's execution time or cost. The only cancellation APIs are session-scoped (session.abort(), session.disconnect()), which kill the whole session including other concurrent sub-agents. A consumer with one runaway sub-agent has to choose between letting it burn cost/SLA or killing the whole session and losing the work of other agents.
Scenario
const session = await client.createSession({
customAgents: [
{ name: "researcher", description: "Codebase research", prompt: "..." }, // expected ~5 min
{ name: "fixer", description: "Apply fixes", prompt: "..." }, // expected ~15 min
],
});
await session.sendAndWait({ prompt: "Dispatch researcher then fixer." });
// On a complex codebase, researcher runs 90 minutes instead of 5.
// There's no way to kill JUST the researcher — only the whole session.
What's missing
CustomAgentConfig currently accepts {name, displayName?, description?, tools?, prompt, mcpServers?, infer?, skills?}. No maxTurnMs, maxTokens, maxToolCalls, or budget field.
Session class exposes session.abort() (cancels the current message, session remains valid — though see #1273 for in-flight sendAndWait still hanging) and session.disconnect() (kills the whole session). No session.agent("name").cancel() or session.cancelSubagent(toolCallId) equivalent.
Suggested API
- Per-agent budget options on
CustomAgentConfig:maxTurnMs,maxTokens,maxToolCalls. SDK/CLI enforces them and emitssubagent.budget_exceededevents when violated. - Per-sub-agent cancellation API:
session.cancelSubagent({ name?, toolCallId? })that kills a specific sub-agent without disconnecting the session.
Consumer impact
Production pipelines with cost or SLA requirements have to layer their own per-agent monitor watching subagent.started / subagent.completed events and tracking per-agent runtime. On overage they either log-and-tolerate (losing cost containment) or kill the whole session (losing work of other concurrent agents). Both choices are bad.
Production observation: a single misbehaving sub-agent (multi-tenant analysis worker) burned ~$150-200 in a single session before the surrounding watchdog hit the per-session ceiling. With a per-agent budget, the loss would have been ~$15.
Related
- #1273 —
session.disconnect()cooperative. Even when consumers detect runaway behavior and try to kill the session, the recovery path is broken. - #1275 —
sendAndWaitreturns prematurely. Without sub-agent completion tracking, consumers also can't reliably know which sub-agents are still running to budget them.
Environment
- SDK: @github/copilot-sdk@0.3.0
- CLI: @github/copilot@1.0.45
- Node: 22 LTS
- OS: Windows 11
- Model: claude-sonnet-4-6
- 主要语言
- Java
- 星标
- 10.5k
- 派生
- 1.5k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 131
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/copilot-sdk 的其他 Issue
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 65/100
github/copilot-sdk#2760 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
github/copilot-sdk#2759 ·
-
documentation
难度 1/5 1 小时以内 新手友好度 85/100
github/copilot-sdk#2758 ·
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 68/100
github/copilot-sdk#2709 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 78/100
github/copilot-sdk#2673 ·
查看 github/copilot-sdk 的全部 Issue
相似的 Issue
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
apache/flink-agents#1152 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
jenkinsci/blueocean-plugin#5417 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
objectionary/eo-graphs#75 ·