Skip to content

Use ExecutionMemento as regular-runner carry-forward state#304

Open
mmprotest wants to merge 1 commit into
mainfrom
mmprotest/add-executionmemento-for-carry-forward-state-d1m72o
Open

Use ExecutionMemento as regular-runner carry-forward state#304
mmprotest wants to merge 1 commit into
mainfrom
mmprotest/add-executionmemento-for-carry-forward-state-d1m72o

Conversation

@mmprotest

Copy link
Copy Markdown
Owner

Motivation

  • Reduce reliance on a long accumulated transcript by carrying a compact structured execution-state snapshot between regular runner turns.
  • Provide a machine- and model-readable memento that states: objective, belief, evidence, scope, attempts, verification outcomes, and next action.
  • Make the change minimally invasive, preserving existing helpers and fallback behavior when the memento is not available.

Description

  • Added villani_code/execution_memento.py implementing ExecutionMemento dataclass and helpers: build_execution_memento, save_execution_memento, load_execution_memento, render_execution_memento_for_model, and build_local_evidence_block and persisted artifacts to .villani_code/missions/<mission_id>/execution_memento.json (/optional .md).
  • Extended MissionState with last_memento_path: str and last_memento_turn_index: int and updated serialization/roundtrip in villani_code/mission_state.py.
  • Triggered memento creation only at meaningful boundaries by adding _refresh_execution_memento() and invoking it from Runner._update_mission_state when key fields change and from validation/result code paths in state_runtime.py.
  • Changed regular-runner prompt assembly to be memento-first: _inject_projected_context now prefers the rendered EXECUTION STATE + tiny LOCAL EVIDENCE block and falls back to the legacy Mission context packet: when required memento fields are missing; prepare_messages_for_model trims long history aggressively for regular (non-small, non-autonomous) runners and preserves tool_use/tool_result adjacency when keeping a short tail.
  • Kept small-model behavior and existing context_projection helpers intact for backward compatibility and preserved tool sequence integrity.

Testing

  • Ran the focused test subset with pytest -q tests/test_mission_state_runtime.py tests/test_state_runtime.py tests/test_session_compaction.py and all tests passed (57 passed).
  • Added/updated targeted tests covering memento persistence, mission-state linkage, memento-first injection and fallback, non-duplication of injection, transcript tail trimming and tool sequence integrity (files updated: tests/test_mission_state_runtime.py, tests/test_state_runtime.py, tests/test_session_compaction.py).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant