Bug
After handoff compaction, <behavioral_directive> blocks injected by spawn into child agent prompts leak into the parent orchestrator session. This causes the parent to believe it is a child agent and refuse orchestration duties.
Root cause
spawn/index.ts:229 injects:
You are a focused child agent spawned by a parent agent...
into child prompts via a <behavioral_directive> wrapper.
When the parent session later calls handoff, handoff/compact.ts compacts the full conversation history — including the spawn prompt text that contained this directive. The compacted output preserves the <behavioral_directive> tag verbatim, promoting it to system-level context in the new clean window.
Reproduction
- Parent orchestrator spawns a child agent
- Child completes, result returns to parent
- Parent calls
handoff (or auto-compaction triggers)
- Post-compaction, parent session now has
<behavioral_directive>You are a focused child agent...</behavioral_directive> in its context
- Parent refuses to orchestrate, claiming it cannot spawn further children
Expected behavior
handoff/compact.ts should strip <behavioral_directive> blocks from the session history before/during compaction. These are transient injection markers for child sessions, not durable parent state.
Workaround
None clean — user must start a new session after the leak occurs.
Environment
- pi 0.78.0
- pi-agenticoding (latest as of 2026-05-31)
Bug
After
handoffcompaction,<behavioral_directive>blocks injected byspawninto child agent prompts leak into the parent orchestrator session. This causes the parent to believe it is a child agent and refuse orchestration duties.Root cause
spawn/index.ts:229injects:into child prompts via a
<behavioral_directive>wrapper.When the parent session later calls
handoff,handoff/compact.tscompacts the full conversation history — including the spawn prompt text that contained this directive. The compacted output preserves the<behavioral_directive>tag verbatim, promoting it to system-level context in the new clean window.Reproduction
handoff(or auto-compaction triggers)<behavioral_directive>You are a focused child agent...</behavioral_directive>in its contextExpected behavior
handoff/compact.tsshould strip<behavioral_directive>blocks from the session history before/during compaction. These are transient injection markers for child sessions, not durable parent state.Workaround
None clean — user must start a new session after the leak occurs.
Environment