fix(agent): persist repaired-turn responses#46071
Conversation
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-attribute |
2 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
run_agent.py:2920: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
✅ Fixed issues (1):
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
Unchanged: 5724 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
Verification: LGTM — solid identity-based flush fixReviewed the full diff. The positional-slice approach ( The replacement using
Test coverage is thorough — 4 new tests in One note: |
|
Live testing added after CI because this touches the core persistence path:
The repair-flow test is the sensitive case from #46053: persisted |
Summary
SessionDB flushing now persists newly appended assistant responses even when message-sequence repair has shortened the live
messageslist belowconversation_historylength.Changes
run_agent.py: replace positional flush slicing with per-session message identity tracking, so history dicts are skipped by identity and newly appended dicts are written once.tests/run_agent/test_identity_flush.py: cover repair-shrunk history, stale cached-agent cursor, same-turn dedup, and cached-agent turn reset.tests/run_agent/test_compression_persistence.py: flip the stale-history regression from documenting the drop to asserting persistence.Validation
python3 -m py_compile run_agent.py tests/run_agent/test_identity_flush.py tests/run_agent/test_compression_persistence.pyscripts/run_tests.sh tests/run_agent/test_identity_flush.py tests/run_agent/test_compression_persistence.py tests/run_agent/test_860_dedup.pyFixes #46053.
Infographic