feat(loop): add REASONIX anti-wandering loop guards - #178
feat(loop): add REASONIX anti-wandering loop guards#178raymondginger2018-sudo wants to merge 3 commits into
Conversation
|
Hi maintainers - just a friendly bump on this PR. It's been open a while without review; happy to rebase onto the latest main and adjust anything you'd like changed. Thanks for your time! |
108257d to
eac5244
Compare
|
CI status update — the lint fix is in and everything relevant is green. Two notes on the remaining red checks:
|
|
CI note on the Python CI test (3.14) failure: The only failing test was Evidence this is flakiness, not a code change:
Pushed an empty commit (e5963df) to retrigger the workflows and confirm. If the 3.14 TUI race reproduces again, I'll look into hardening the pause-vs-exit ordering in the goal store. (Security CI failure on this branch is the repo-wide pip advisory — tracked in #191.) |
Port the REASONIX anti-wandering guard family (evidence ledger, progress guard, storm breaker, delegation admission) into the agent runtime loop: - core/loop/guards.py: guard engine (stdlib-only, no internal deps) - core/loop/guard_telemetry.py: optional telemetry seam - runner.py: blocked short-circuit, observe_batch injection, per-tool check_tool gate, success-path observation wiring - session.py: thread LoopGuards instance through AgentSession/AgentRunSpec - spawn_agent.py: delegation admission gate (REASONIX delegationAdmission) - loop/__init__.py: public exports Origin: Python port of the applyBatchGuards component family from DeepSeek-Reasonix (https://github.com/esengine/DeepSeek-Reasonix, MIT licensed), adapted to DeepCode's run-loop conventions. Implementation is a fresh Python rewrite, not a code copy.
Apply the CI ruff rules (3 auto-fixes) and ruff-format to the loop guard modules and their tests; no logic changes. guards test suite: 37 passed.
Python CI test (3.14) failed once on test_goal_edit_and_steer_remain_available_while_work_runs_in_background (goal PAUSED vs BLOCKED race) while the semantically identical parent commit a4ec71c passed the full matrix including 3.14. Triggering a rerun to confirm the failure is timing flakiness, not a code change.
e5963df to
5c21fad
Compare
|
Hi Zongwei, REASONIX anti-wandering loop guards. Minimal changes to existing code (runner.py imports only, plus new guard modules). Rebased onto latest main (e0767d0), all 14 CI checks green. Ready for review. Thanks! |
Summary
Adds anti-wandering loop guards to the agent runtime loop: an evidence ledger, a progress guard, a storm breaker, and delegation admission. When the model starts spinning (repeated tool calls producing no new evidence), the guards inject escalating interventions and can force a final answer instead of burning the remaining budget on the same failure pattern.
The engine lives in
core/loop/guards.py(stdlib-only, zero internal dependencies) with an optional telemetry seam incore/loop/guard_telemetry.py(enabled viaDEEPCODE_GUARD_TELEMETRY=1, zero overhead by default).Wiring
runner.py— blocked short-circuit before tool execution,observe_batchinjection after each tool batch, per-toolcheck_toolgovernance gate, and success-path observation hooks.session.py— threads aLoopGuardsinstance throughAgentSession→AgentRunSpec.spawn_agent.py— delegation admission gate (REASONIXdelegationAdmissionadaptation) so a sub-agent that references parent-context without inheriting it (fork_turns='none') is rejected with an actionable error.loop/__init__.py— public exports for the guard API.Behavior notes
guards: LoopGuards | None = NoneonAgentRunSpec; absent means zero cost.guard_event_callbackreceives structured events (blocked/injection/tool_block) for telemetry without changing default logging behavior.Testing
tests/test_guards.py— evidence ledger scoring, progress-guard escalation (2/4/6), storm-breaker circuit breaking, delegation admission.tests/test_guard_telemetry.py— telemetry wiring and event payloads.Origin
This is a Python port of the
applyBatchGuardscomponent family (evidence ledger, progress guard, storm breaker, delegation admission) from DeepSeek-Reasonix (MIT licensed), adapted to DeepCode's run-loop conventions. The implementation is a fresh Python rewrite following the original design semantics — not a code copy. Original project:esengine/DeepSeek-Reasonix(MIT License).