Skip to content

feat(sub-agent): with_execution_limits — the token and duration caps are no longer hard-coded - #238

Merged
yuanhao merged 4 commits into
mainfrom
feat/sub-agent-limits
Oct 5, 2026
Merged

yuanhao merged 4 commits into
mainfrom
feat/sub-agent-limits

Conversation

@yuanhao

@yuanhao yuanhao commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Problem: SubAgentTool built every delegation's limits with a hard-coded 1M tokens and 300 s, commented "generous". Only with_max_turns could be changed. Since the token count includes every turn's whole prompt (see #237), a sub-agent working over a large context reached 1M within a few turns: about 3 turns at 400K, or about 16 at 60K. Nothing could raise it.

Change:

  • SubAgentTool stores a full ExecutionLimits.
  • New with_execution_limits(ExecutionLimits) replaces all of the limits.
  • with_max_turns(n) still works and changes only the turn count.
  • Defaults are unchanged (10 turns, 1M tokens, 300 s, loop detection on), so nothing changes unless a caller opts in. The API change is additive.

Tests:

  • A delegation whose turns each report a 400K-token prompt stops at the token cap by default, and finishes once the cap is raised.
  • with_max_turns after with_execution_limits changes only the turns: the run stops at the turn cap, not the token cap.

Docs: docs/concepts/sub-agents.md (a Limits section with an example), the CHANGELOG and CLAUDE.md. Once #237 is merged, I'll update its line saying with_max_turns is a sub-agent's only setting.

Local checks: fmt, clippy (all features, no default features, wasm32), docs, and cargo test --all-features (55 binaries).

🤖 Generated with Claude Code

https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG

yuanhao and others added 4 commits October 6, 2026 00:06
…re no longer hard-coded

SubAgentTool built each delegation's limits with a hard-coded 1M tokens
and 300 s; only with_max_turns was adjustable. Since the token count
includes every turn's whole prompt, a sub-agent over a large context hit
1M within a few turns and nothing could raise it. The tool now stores an
ExecutionLimits: with_execution_limits replaces it, and with_max_turns
changes only the turns. Defaults are unchanged (10 turns, 1M, 300 s, loop
detection on).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
…e reset; list with_execution_limits in the builder table

Review fixes for #238.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
…gurable in the context guide

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
@yuanhao
yuanhao merged commit c7ecd66 into main Oct 5, 2026
14 checks passed
@yuanhao
yuanhao deleted the feat/sub-agent-limits branch October 5, 2026 22:21
yuanhao added a commit that referenced this pull request Oct 5, 2026
Reliability fixes from the October codebase review (#232-#235, #237, #238).


Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant