feat(sdk): give parents a resume_agent tool - #6
Merged
Conversation
The parent's system prompt already told it that a paused child sends a <child-paused> message and that it may "resume it (after addressing the cause)". Nothing backed that instruction: resume existed only as a plugin method, reachable from outside the session via agents.resume, and the agents plugin handed the parent nothing but start_<agent_name> tools. So a child that paused stayed paused. The parent was notified, was told to resume it, and had no way to do so — the same shape as a prompt telling an agent to run `git push` where a handler blocks it and a separate tool exists. resume_agent wraps the existing method the way start_<agent_name> wraps spawn, and only appears for agents that can spawn. It refuses agents that are not the caller's own children, which the method itself does not check because it is also the external RPC surface. Resuming deliberately does not grant budget — costSpent/tokensUsed are not reset on resume, so a child that hit a cost limit stops again immediately. Both the tool description and the prompt now say so, so the parent does not retry it in a loop. Closes #5 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018yiScAyGwDx3A3DqaUasEA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5.
The gap
The parent's system prompt (
plugins/agents/plugin.ts) told it:Nothing backed that. The notification path is fine — I traced it end to end:
self.senddispatches throughpluginMethodCaller('mailbox', 'send', …), the same path as any inter-agent message, so the parent really is woken. Butresumeexisted only as a plugin method — the external RPC surfaceagents.resume— and.tools()handed the parent nothing butstart_<agent_name>.grep -rn "name: 'resume" packages/sdk/srcreturned nothing.So a paused child stayed paused: the parent was notified, was instructed to resume it, and had no tool to call. Same shape as a prompt telling an agent to run
git pushwhere a handler blocks it and a separategit_pushtool exists.What this adds
resume_agent, wrapping the existing method the waystart_<agent_name>wrapsspawn. It:costSpent/tokensUsedare deliberately not reset on resume (so the cap can't be bypassed by pause/resume), which means a child that hit a cost limit stops again immediately. Saying so keeps the parent from retrying in a loop.Why now
contember/webmaster#512just registeredlimitsGuardPluginon the customer-facingedit,previewandcoding-onlypresets — it had been onredoonly. That widened the set of ways a child can pause in front of a paying customer, which is what surfaced this.Still open, out of scope here
On the webmaster side
budget_exceeded/limit_warningare surfaced nowhere in the worker or the app, so a tripped limit still reads to the end user as "the agent stopped answering". Tracked in that repo'spackages/agent/STATUS.md.Verification
bun run ts:buildclean,bun run lintclean (one pre-existing unrelated warning), full suite 907 pass / 8 skip / 0 fail.Three new integration tests: the tool is offered to a spawning agent and not to a leaf; an orchestrator resumes its own paused child; and resuming a grandchild is refused with
not your childwhile the grandchild stays paused.🤖 Generated with Claude Code
https://claude.ai/code/session_018yiScAyGwDx3A3DqaUasEA