feat(subagent): add delegation-mode gating and token-level transcript streaming#6537
Merged
Merged
Conversation
… streaming Adds a tri-state delegation_mode (disabled/explicit_request_only/proactive) to SubAgentConfig so an operator can restrict which spawn paths are allowed without disabling sub-agents entirely, closing a prompt-injection-relevant gap where the autonomous orchestration scheduler could not be distinguished from an explicit user-triggered spawn. Enforcement is fail-closed via a new SpawnContext.origin field that defaults to the restrictive value, and every real spawn call site (manager spawn/spawn_for_task, /agent resume, the ACP /subagent spawn path) is audited and gated behind a shared allow-list predicate. Extends live subagent transcript forwarding (forward_transcript) with token-level intra-turn streaming on providers with native streaming-with- tools support, reusing the existing AnyProvider::chat_with_tools_stream path rather than adding a new provider-trait method. Non-streaming backends keep the prior once-per-turn forwarding unchanged. The forwarding drain now buffers deltas with a bounded holdback window before sanitizing, closing a masking gap where a secret/PII pattern split across two delta boundaries could reach forwarded output unmasked.
bug-ops
enabled auto-merge (squash)
July 20, 2026 02:37
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.
Summary
delegation_mode(disabled/explicit_request_only/proactive) toSubAgentConfigso an operator can restrict which spawn paths are permitted without disabling sub-agents entirely — e.g. block the autonomous orchestration scheduler from spawning while still allowing explicit/agent spawn//agent resume(parity: zeph-subagent lacks disabled/explicit-request-only/proactive delegation-mode control (Codex pattern) #5857). Enforcement is fail-closed:SpawnContext.origindefaults to the restrictiveAutonomousvalue, and every real spawn call site (manager spawn/spawn_for_task,/agent resume, the ACP/subagent spawnpath) is audited and gated behind a sharedDelegationMode::permits_explicit()allow-list.AnyProvider::chat_with_tools_streampath rather than adding a new provider-trait method (subagent: token-level intra-turn transcript streaming (FR-002b, follow-up to #6359) #6456). Non-streaming backends keep the prior once-per-turn forwarding unchanged. The forwarding drain now buffers deltas with a bounded holdback window before sanitizing, closing a masking gap where a secret/PII pattern split across two delta boundaries could reach forwarded output unmasked.Closes #5857
Closes #6456
Notes
.local/specs/046-subagent-peer-messaging-parity/spec.md) has 4 unresolved open questions, introduces a new spawn-tree authorization boundary warranting its own dedicated security pass, and has heavy file overlap with this PR's changes that would force serialized edits if bundled. Not included here.claude-haiku-4-5-20251001with a 2-turn, tool-call-containing prompt via/agent bgunder--bare --forward-subagent-text. Confirmed well-formed request/response payloads, no 400/422, and the native per-delta streaming path firing (4 forwarded chunks across 2 turns instead of the 2 FR-002a alone would produce). Details in.local/testing/playbooks/subagent-token-streaming.md.Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins(14833/14833 passed)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler")gitleaks protect --staged.local/testing/playbooks/subagent-delegation-mode.md,.local/testing/playbooks/subagent-token-streaming.md,.local/testing/coverage-status.md)