fix(state): don't clear in-flight turn marker when canonical flush fails - #74540
Conversation
43ed441 to
d173b9d
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the meaningful False return from the SQLite flush.
Problems
run_agent.py:1860changes the tripwire's semantics, butagent/agent_runtime_helpers.py:482-485explicitly says the marker is cleared unconditionally so this diagnostic under-reports rather than emits false overlap reports. With this change, a completed turn whose flush fails leaves the marker behind; the next serial turn is then treated as an overlap bynote_turn_start()atagent/agent_runtime_helpers.py:429-444.- The new boolean return does not yet establish a caller-visible persist contract: the normal finalizer discards
_persist_session()'s result atagent/turn_finalizer.py:352.
Suggested changes
- Keep the overlap marker's unconditional clear. Surface failed SQLite persistence through a separate diagnostic or recovery path rather than using a concurrency tripwire.
- Add a regression test for a failed flush followed by a serial turn, ensuring only real concurrent turns trigger the overlap warning.
Automated hermes-sweeper review.
| # Skipping note_turn_persisted on failure preserves the evidence | ||
| # that the previous turn never completed its persist, so the turn | ||
| # overlap tripwire can still catch a real boundary failure. | ||
| if flush_ok is not False: |
There was a problem hiding this comment.
Retaining this marker makes the next serial turn look like a concurrent overlap: note_turn_start() warns whenever a prior marker remains (agent/agent_runtime_helpers.py:429-444). The tripwire was explicitly made unconditional to avoid noisy diagnostics (agent/agent_runtime_helpers.py:482-485, commit 59787b9ada6). Please preserve that clear and report flush failure through a separate signal.
The previous approach (gating note_turn_persisted on flush_ok) would leave the in-flight turn marker set when a SQLite flush failed. The next serial turn would then be falsely flagged as a concurrent overlap. Instead: - Keep the in-flight marker clear unconditional (design contract in note_turn_persisted: "unconditional by design — a diagnostic must never be noisier than the defect it hunts") - Surface a failed flush through a separate logger.warning with turn_id and session_id context - Return type reverts to None (the finalizer discards it anyway) Follows discussion at PR NousResearch#74540 hermes-sweeper review.
d173b9d to
5bca320
Compare
|
Thanks for the review, hermes-sweeper. I have redesigned the approach based on the feedback. Changes:
Rationale per the suggestion:
|
SummaryTwo PRs address #74284 by reacting to an explicit Related pull requests
Duplicates#74305 and #74540 target the same Suggested consolidationKeep #74540 open with a salvage path: retain the separate persistence-failure diagnostic, preserve unconditional overlap-marker clearing, and add the contributor-requested regression test proving that a failed flush followed by a serial turn does not emit a false overlap warning. The revised behavior must be visible in the actual diff before consolidation; close #74305 as a duplicate of #74540 because its supplied diff retains the marker and therefore conflicts with the documented tripwire design. Complex graphflowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
I74284(["issue #74284 (open)"])
subgraph Dup74305 ["PRs duplicating each other"]
P74305["PR #74305 (open)"]
P74540["PR #74540 (open)"]
end
P74540 -->|best fix| I74284
class I74284 open
class P74305 open
class P74540 open
class P74305 best
class P74540 best
class P74540 target
click I74284 "https://github.com/NousResearch/hermes-agent/issues/74284"
click P74305 "https://github.com/NousResearch/hermes-agent/pull/74305"
click P74540 "https://github.com/NousResearch/hermes-agent/pull/74540"
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label). Cross-PR triage: Reviewed 2 pull requests and 1 issue in this complex. Diffs were read for 1 of 2 PRs (rest unavailable); Assessment working set: 5 kB of PR diffs, 6 kB of issue/PR text, 3 kB of discussion (3 comments), 6 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch. |
Summary
AIAgent._persist_session()callednote_turn_persisted()unconditionally, even when_flush_messages_to_session_db()returnedFalse(SQLite write failure on exception). This made the runtime overstate success: the turn overlap tripwire lost the evidence that the previous turn never completed its persist.Changes
_flush_messages_to_session_dbreturns:Trueon success — clear the in-flight markerNonewhen persist is disabled or no session DB exists — consistent state, still clearFalseon exception — do not clear the marker, preserve the evidenceRelated
Closes #74284