You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Agent PreToolUse hook appends the full <context_window_protection> routing block to every subagent prompt, instructing it that it MUST use ctx_* tools for analysis/fetch. When a subagent runs in the foreground (the default for Claude Code's Agent tool) and one of those forced ctx_* calls blocks (sandbox runtime startup, or a network call in ctx_fetch_and_index with no surfaced timeout), the entire parent session freezes until the user hard-interrupts, which can lose the subagent's work.
There is currently no opt-out. I'd like to request a first-class one (env var and/or per-subagent-type skip).
Environment
context-mode 1.0.162 (plugin via marketplace, autoUpdate on)
Claude Code CLI, Windows 11, model Opus 4.8
MCP server running normally in the main session (ctx_doctor all green)
Env-var opt-out, e.g. CONTEXT_MODE_DISABLE_AGENT_INJECTION=1, checked in the canonical === "Agent" branch of routing.mjs, returning pass-through instead of the modified prompt.
At minimum, document that the Agent injection exists and how to disable it.
Rationale for opt-out over removal: the injection is genuinely valuable in the main session (it kept ~28 MB out of context in one of my sessions). But a subagent has its own isolated, short-lived context, and the parent only ever sees the subagent's summary, so the in-subagent ctx_* benefit is small while the hang risk is real. An opt-out keeps the default behavior for those who want it.
Current workaround
A local self-healing SessionStart hook that strips the Agent matcher from the plugin's hooks.json after each update (idempotent, pure Node stdlib, never imports from the plugin dir). It works, but it edits plugin-cache files and must re-apply on every version bump, so a supported flag would be much cleaner.
Happy to send a PR for option 1 if you're open to it.
Summary
The
AgentPreToolUse hook appends the full<context_window_protection>routing block to every subagent prompt, instructing it that it MUST usectx_*tools for analysis/fetch. When a subagent runs in the foreground (the default for Claude Code'sAgenttool) and one of those forcedctx_*calls blocks (sandbox runtime startup, or a network call inctx_fetch_and_indexwith no surfaced timeout), the entire parent session freezes until the user hard-interrupts, which can lose the subagent's work.There is currently no opt-out. I'd like to request a first-class one (env var and/or per-subagent-type skip).
Environment
ctx_doctorall green)Why the existing fixes don't fully cover this
ctx_*resolve. That fixed one stall cause (the tool-not-found loop). It did not remove the broader failure mode: a subagent that successfully starts actx_*call which then blocks. The follow-up mentioned there, "skip injection entirely for Explore-type read-only subagents", does not appear to have shipped:hooks/core/routing.mjs(1.0.162, around L817-838) still injects for allAgentspawns regardless ofsubagent_type(onlyBashis special-cased, and it's rewritten togeneral-purpose).ctx_*unavailability for fixed-tool subagents.Proposed (any one resolves it)
CONTEXT_MODE_DISABLE_AGENT_INJECTION=1, checked in thecanonical === "Agent"branch ofrouting.mjs, returning pass-through instead of the modified prompt.Explore, etc.), optionally a configurable allow/deny list as suggested in [Bug]: Context Mode should not take over cc tool call that would run inside subagents #155.Rationale for opt-out over removal: the injection is genuinely valuable in the main session (it kept ~28 MB out of context in one of my sessions). But a subagent has its own isolated, short-lived context, and the parent only ever sees the subagent's summary, so the in-subagent
ctx_*benefit is small while the hang risk is real. An opt-out keeps the default behavior for those who want it.Current workaround
A local self-healing SessionStart hook that strips the
Agentmatcher from the plugin'shooks.jsonafter each update (idempotent, pure Node stdlib, never imports from the plugin dir). It works, but it edits plugin-cache files and must re-apply on every version bump, so a supported flag would be much cleaner.Happy to send a PR for option 1 if you're open to it.