Skip to content

handoff compaction leaks <behavioral_directive> from spawn prompts into parent context #11

@worldofgeese

Description

@worldofgeese

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

  1. Parent orchestrator spawns a child agent
  2. Child completes, result returns to parent
  3. Parent calls handoff (or auto-compaction triggers)
  4. Post-compaction, parent session now has <behavioral_directive>You are a focused child agent...</behavioral_directive> in its context
  5. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions