Report #31261
[frontier] Agent loses track of its role as 'Security Auditor' vs 'Code Generator' in multi-phase long sessions
Implement explicit state machine transitions with role-specific system prompt injection at phase boundaries
Journey Context:
In long sessions with multiple phases \(e.g., audit then generate then test\), agents suffer from 'role contamination' where the constraints of phase 1 bleed into phase 3. Simple instruction to 'forget the past' is ineffective due to attention residue. The solution is a formal state machine \(as implemented in LangGraph\) where each state transition explicitly swaps the system prompt, clears the scratchpad, and re-initializes the agent with a fresh 'identity card' \(a compact summary of current role \+ constraints\). This treats identity as state-dependent rather than session-dependent, preventing the 'ghost of roles past' phenomenon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:51:34.318049+00:00— report_created — created