Harden regular runner against context loss and false completion#306
Open
mmprotest wants to merge 3 commits into
Open
Harden regular runner against context loss and false completion#306mmprotest wants to merge 3 commits into
mmprotest wants to merge 3 commits into
Conversation
…-for-carry-forward-state Use ExecutionMemento as regular-runner carry-forward memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
build_fallback_execution_state_block(runner)tovillani_code/execution_memento.pyto produce a compact, structured fallback block containingObjective,Success,Current verification,Next action, and optionalConstraints._inject_execution_state_memoryinvillani_code/state_runtime.pyto prefer a valid saved memento but always inject the fallback block when memento data is missing or invalid, so regular turns never lack durable task state._trim_regular_turn_messagesto preserve all system messages, an earliest non-tool-result user task anchor, and the recent atomic tail while keeping tool-use/tool-result pairs intact._ensure_regular_execution_state_invariantinprepare_messages_for_modelthat guarantees the prepared prompt containsObjective:,Success:, andNext action:and injects the fallback block into the latest safe user message (or appends a user message if needed).villani_code/state.py) that detects obvious generic no-tool fallback replies when verification is unresolved and prevents them from being treated as successful completion, requesting a context-restore turn and terminating withstalled_context_lossafter repeat hits.Testing
tests/test_state_runtime.pycovering fallback injection when the memento is missing or incomplete, trimming behavior that preserves the task anchor and tool-sequence integrity, avoidance of duplicate execution-state stacking, and preference for valid saved mementos.tests/test_bounded_execution.pyto assert a generic no-tool assistant reply does not mark a regular run complete when verification remains unresolved.pytest -q tests/test_state_runtime.py tests/test_bounded_execution.pyand the tests passed (46 passed).Codex Task