You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The harness currently invokes CC in single-shot print mode (claude -p "<prompt>") — a fresh process per turn that receives the entire context as input. Switch to claude --resume so each turn continues an existing CC session instead of starting a new one.
Why
Token cost.-p resends the full conversation history on every turn (system prompt, project prompt, prior <msg> envelopes, prior tool I/O). With --resume, CC maintains its own session, so each turn only sends the new inbound message + tool results. Especially significant for long-running chats and the daily self-reflection skill.
Latency. Less to send / parse on each turn → faster first-token.
Cache hit rate.--resume keeps the prompt cache warm across turns; -p rebuilds prompt-prefix every time. The Anthropic cache TTL is 5 minutes — --resume actually benefits from it, -p rarely does.
Natural memory model. Working context lives inside CC's session, not reassembled by the harness each turn.
Trade-offs / risks
Loss of per-turn isolation. With -p, every turn starts from a known, sanitized prompt. With --resume, prior turn's state (including any successful prompt injection) persists. Mitigations: the auto-restart-on-wedge work in Encoded prompt injections (base64, Morse) crash Claude Code sessions #39, plus an explicit "reset session" path the harness can trigger on detected compromise.
Add a CLI knob to opt back into -p mode for debugging.
Severity
Feature, but high leverage — touches cost, latency, and the foundation that #39 / #40 / #41 build on. Worth treating as a small redesign, not a one-line patch.
Summary
The harness currently invokes CC in single-shot print mode (
claude -p "<prompt>") — a fresh process per turn that receives the entire context as input. Switch toclaude --resumeso each turn continues an existing CC session instead of starting a new one.Why
-presends the full conversation history on every turn (system prompt, project prompt, prior<msg>envelopes, prior tool I/O). With--resume, CC maintains its own session, so each turn only sends the new inbound message + tool results. Especially significant for long-running chats and the daily self-reflection skill.--resumekeeps the prompt cache warm across turns;-prebuilds prompt-prefix every time. The Anthropic cache TTL is 5 minutes —--resumeactually benefits from it,-prarely does.Trade-offs / risks
-p, every turn starts from a known, sanitized prompt. With--resume, prior turn's state (including any successful prompt injection) persists. Mitigations: the auto-restart-on-wedge work in Encoded prompt injections (base64, Morse) crash Claude Code sessions #39, plus an explicit "reset session" path the harness can trigger on detected compromise./pause→/resume? On any anomaly? Worth designing alongside Encoded prompt injections (base64, Morse) crash Claude Code sessions #39 and Feature: /pause and /resume slash commands #41.--resumerequires a session ID. Harness needs to persist the active session ID across container restarts and recover gracefully if the ID is gone.--resumestreaming format may differ from-pJSON-mode output — adapter layer needs review.Suggested implementation steps
claude --resume <session_id>with just the new inbound<msg>envelope(s). Stream tool calls + replies as usual./pause+/resume(Feature: /pause and /resume slash commands #41), tear down the session and spin a new one.-pmode for debugging.Severity
Feature, but high leverage — touches cost, latency, and the foundation that #39 / #40 / #41 build on. Worth treating as a small redesign, not a one-line patch.