feat(sub_agent): add mission_log_in format option for prompt caching#1022
feat(sub_agent): add mission_log_in format option for prompt caching#1022andreasronge wants to merge 2 commits into
Conversation
Allow configuring where the mission log is injected via `format_options: [mission_log_in: :user_message]`. This keeps the system prompt static across turns, enabling LLM prompt caching for long-running multi-turn agents with journaling enabled. Default remains `:system_prompt` (no breaking change). The mission log is injected fresh into the first user message each turn, so it reflects the current journal state without polluting state.messages. Closes #785 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Review: feat(sub_agent): add mission_log_in format option for prompt cachingSummaryClean, well-scoped feature that adds What's Good
Issues (Must Fix)
Suggestions (Optional)
SecurityNo concerns. The change only affects where existing content is placed in the LLM prompt (system prompt vs. user message). No new user input paths, no new external calls. Documentation
VerdictRequest Changes — The implementation is solid and well-tested, but the guide documentation gap should be closed before merge. It's a mechanical fix (one table row + short note). |
|
@claude please fix:
|
Auto-Triage Summary
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix Summary✅ Issue Fixed: Added Added a new row to the format_options table documenting the |
PR Review: feat(sub_agent): add mission_log_in format option for prompt cachingSummaryWell-executed feature that adds What's Good
Issues (Must Fix)None. Suggestions (Optional)
SecurityNo concerns. The change only affects where existing content (the rendered mission log) is placed in the LLM prompt. No new user input paths, no new external calls. Documentation
VerdictApprove — Clean implementation that follows existing patterns, with thorough tests and complete documentation. The prior review's documentation gap has been addressed. Ready to merge. |
Auto-Triage Summary
No FIX_NOW items — added |
Summary
format_options: [mission_log_in: :user_message]to control where the mission log is injected:user_message, the system prompt stays static across turns, enabling LLM prompt caching:system_promptpreserves existing behavior — no breaking changeCloses #785
Changes
lib/ptc_runner/sub_agent/definition.ex:mission_log_intoformat_optionstypespec (:system_prompt | :user_message)lib/ptc_runner/sub_agent/loop.exbuild_system_prompt/6: Skip mission log whenmission_log_in: :user_messagemaybe_inject_mission_log_in_messages/3: Inject mission log into the first user message each turn (after compaction, so state.messages stays clean and compaction can't discard it)test/ptc_runner/sub_agent/journal_test.exs:system_promptmode preserves existing behaviorTest plan
:user_messagemodemix precommitpasses (format + compile + credo + tests)🤖 Generated with Claude Code
Fix Automation State
Fix attempts: 2/3