Skip to content

fix(routing): self-identify subagent routing block, add opt-out (#967) - #1034

Open
kaovilai wants to merge 1 commit into
mksglu:nextfrom
kaovilai:fix-967-upstream
Open

fix(routing): self-identify subagent routing block, add opt-out (#967)#1034
kaovilai wants to merge 1 commit into
mksglu:nextfrom
kaovilai:fix-967-upstream

Conversation

@kaovilai

@kaovilai kaovilai commented Aug 4, 2026

Copy link
Copy Markdown

What / Why / How

Auto-mode permission classifiers sometimes read the injected <context_window_protection> block in Agent-tool dispatch prompts as a prompt-injection payload and veto the subagent spawn itself (~40% of spawns in the reporter's session).

  • Wrap the block in a <provenance> tag when routed into a subagent prompt, identifying it as trusted first-party config from a locally installed plugin rather than injected third-party content.
  • Add a CONTEXT_MODE_SUBAGENT_ROUTING opt-out (0/false/off/no) to skip the injection entirely for security-conscious setups.

Fixes #967

Related to #911 / #918 (also about the injected block reading as injection-shaped to classifiers, addressed there via renaming <priority_instructions><usage_hint> and trimming <session_continuity>) — this PR is complementary: it adds explicit provenance/self-identification plus a hard opt-out, rather than softening wording. No overlapping lines once #918 lands; happy to rebase if it merges first.

Affected platforms

  • Claude Code
  • Cursor
  • VS Code Copilot (GitHub Copilot)
  • JetBrains Copilot
  • Gemini CLI
  • Qwen Code
  • OpenCode
  • KiloCode
  • Codex CLI
  • OpenClaw (Pi Agent)
  • Pi
  • Kiro
  • Antigravity
  • Zed
  • All platforms

Test plan

  • Added/extended tests in tests/core/routing.test.ts and tests/hooks/core-routing.test.ts covering the <provenance> wrapper and the CONTEXT_MODE_SUBAGENT_ROUTING opt-out (including truthy/falsy env var variants).

Checklist

  • Tests added/updated (TDD: red → green)
  • npm test passes
  • npm run typecheck passes
  • Docs updated if needed (README, platform-support.md) — README note added
  • No Windows path regressions (forward slashes only)
  • Targets next branch

Note

Responses generated with Claude

…lu#967)

Auto-mode permission classifiers sometimes read the injected
<context_window_protection> block in Agent-tool dispatch prompts as a
prompt-injection payload and veto the spawn itself.

- Wrap the block in a <provenance> tag identifying it as trusted
  first-party config from a locally installed plugin, not injected
  third-party content, when routed into a subagent prompt.
- Add CONTEXT_MODE_SUBAGENT_ROUTING opt-out (0/false/off/no) to skip
  the injection entirely for security-conscious setups.

Fixes mksglu#967

Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.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