Context
We're building a qa agent. It has an orchestrator agent that dispatches work to custom sub-agents via the task tool. We use session-level onPostToolUse hooks to enforce guardrails (retry limits on failing tests). The hooks fire correctly during sub-agent execution — we can see hook.start/hook.end events in the session journal, and onPreToolUse denials work as expected inside sub-agents.
What we observe
We have a guardrail that tracks test failures per spec. After 3 failures, we want to tell the sub-agent "stop retrying, mark as fixme, move on." Currently our hook calls session.send({ prompt: text, mode: "immediate" }) separately. The sub-agent ignores this and keeps retrying (7+ attempts observed).
Before max attempts, we return { additionalContext: feedbackText } from the hook (per-attempt guidance like "attempt 2/3, try a different approach"). We haven't been able to confirm whether this feedback actually reaches the sub-agent.
Questions
- Does
{ additionalContext } returned from onPostToolUse get injected into the active sub-agent's context, or only the parent session?
- Does
session.send({ mode: "immediate" }) reach a running sub-agent, or does it queue on the parent session?
- What is the recommended way to steer a sub-agent mid-turn from a hook?
Environment
@github/copilot-sdk@1.0.6
@github/copilot@1.0.70
- Custom agents with
tools: null (all tools)
- Hooks registered at session creation via
hooks: { onPreToolUse, onPostToolUse }
Context
We're building a qa agent. It has an orchestrator agent that dispatches work to custom sub-agents via the
tasktool. We use session-levelonPostToolUsehooks to enforce guardrails (retry limits on failing tests). The hooks fire correctly during sub-agent execution — we can seehook.start/hook.endevents in the session journal, andonPreToolUsedenials work as expected inside sub-agents.What we observe
We have a guardrail that tracks test failures per spec. After 3 failures, we want to tell the sub-agent "stop retrying, mark as fixme, move on." Currently our hook calls
session.send({ prompt: text, mode: "immediate" })separately. The sub-agent ignores this and keeps retrying (7+ attempts observed).Before max attempts, we return
{ additionalContext: feedbackText }from the hook (per-attempt guidance like "attempt 2/3, try a different approach"). We haven't been able to confirm whether this feedback actually reaches the sub-agent.Questions
{ additionalContext }returned fromonPostToolUseget injected into the active sub-agent's context, or only the parent session?session.send({ mode: "immediate" })reach a running sub-agent, or does it queue on the parent session?Environment
@github/copilot-sdk@1.0.6@github/copilot@1.0.70tools: null(all tools)hooks: { onPreToolUse, onPostToolUse }