Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add per-sub-agent timeout / token budget / cancellation API

Open
#1,276 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
node.js, typescript
Domain
api

Research direction

Start with the CustomAgentConfig and Session APIs described in the issue, reviewing the existing session.abort(), session.disconnect(), and subagent.started/subagent.completed entry points. Define how per-agent budgets, budget-exceeded events, and targeted cancellation should behave, then verify that one sub-agent can be stopped without disconnecting the session.

Written by the indexing model from the issue text.

Description

enhancement
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 emits subagent.budget_exceeded events 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 — sendAndWait returns 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
Dominant language
Java
Stars
10.5k
Forks
1.5k
Avg merge
1d 9h
Merged PRs (30d)
131

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/copilot-sdk

All issues in github/copilot-sdk

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.