Skip to content

receive loop: hold a conversation answered none or paused until a newer message (1.5.1) - #33

Merged
sanctrl merged 3 commits into
mainfrom
fix/hold-stuck-conversation
Nov 20, 2026
Merged

sanctrl merged 3 commits into
mainfrom
fix/hold-stuck-conversation

Conversation

@sanctrl

@sanctrl sanctrl commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

What changes

When an agent's AI cannot process a conversation and the server answers the kit's could-not-process report with none or paused, integration.ReceiveLoop used to run that conversation again on its next cycle on the same input. The trigger could be a message in any conversation, a wake frame, a reconnect, a wake the integration heard, or a turn's end. The run failed the same way and sent the same messages to the model every time. The loop now holds the conversation at the anchor it reported (a failed message is not redelivered; new messages flow):

  • No cycle runs or gates it while its card still shows that anchor. An unanswered re-wake does not lift the hold.
  • A run or reply turn of it at that anchor does not start. One waiting for a slot is dropped (on none too, as on paused). One decided before the answer came is checked again when it starts. A run already under way that ends silent there does not lift the hold.
  • A newer message in the conversation ends the hold, and a failure on it is handled afresh, starting from retry. A verdict or mark-read that takes the card off a complete tray ends it too.
  • The hold is in memory. A restart may try the conversation once more, and that report holds it again. Holds are bounded like the loop's other per-conversation memory, and apart from D5 paces, so paces never push a hold out.

A failure reported later (on another conversation's completion, or on the runtime check) now holds its conversation from the moment its report is due until the server answers, as one reported at its own end already did. No cycle gates or runs it meanwhile, and a run or turn of it waits for the answer. Before this, the freed slot could start it on the input the answer was about.

Status:

  • processingFailures.held lists conversationId, anchor, since and reason, so integrations' status/doctor can say "not retried until a new message arrives".
  • processingFailures.startsHeld counts the runs and turns not started because of a hold.
  • CycleSummary.heldAfterFailure counts the cards a cycle left out.

All three are optional in the types (always set by the loop), so status objects built elsewhere keep compiling. Existing fields are unchanged.

Version 1.5.1 (a patch: it fixes existing behaviour, per VERSIONING.md), with a CHANGELOG section ## 1.5.1 — 2026-11-20. README and docs/integration-kit.md are updated. No tag is created here: publishing is the separate, approved release step.

Verification

  • Tests: type-check clean; test 903 passed in 30 files (14 new could-not-process tests and one existing expectation updated: a run of the conversation queued behind the evidence is now dropped on none); build ok; scripts/check-contract-fixtures.sh matches the published contract. The new tests cover: none held through a message elsewhere, a wake frame, an unanswered re-wake and a reconnect while the other conversations keep running, with a newer message lifting the hold and the next failure getting retry; a waiting run that waits for the answer (none drops it, retry starts it once); paused; a card read meanwhile, and a truncated tray proving nothing; gate-call mode (reply turns and single-card gate calls); the runtime-check path; the three start-time races; a newer-anchor run kept on none and dropped on paused; a silent run under way not lifting the hold; no wake loop while a turn runs; and the Pacer's bounds and read ordering. The new tests fail against the 1.5.0 loop.
  • Review: an independent review of the diff (no conclusions given to the reviewer) found one real bug: the hold and the report-in-flight mark were checked only when a cycle read the tray, never when a run or turn started. That left three race windows: an answer landing while a gate call carrying the card was out; a turn launched into a free slot while its report was out; and an answer landing during a slow readiness check. In each, the conversation could start once more on the held input. It also raised a reporting leak if the turn-end path threw, a pace replacing a hold at the same anchor, required new type members (a compile break for integrations that build status objects), status not clearing a hold whose card moved to a newer anchor, and doc inaccuracies. All are fixed and covered by the new tests; the reviewer's probes now show the conversation staying held. A re-review of the fixes found one regression they introduced: a wake at the end of the runtime check that could spin the gate while a turn ran on. That is fixed (the end of a report wakes only for a card a cycle left out because its report was out), and a test pins one wake to one cycle (it fails with the regression: 161 cycles).
  • Live check: after release, lab live-fire on coding-1 with a stand-in failing runtime.

Also in this PR: the contract v1 fixtures copied byte for byte from the published contract (manual 2.4.1), the established fixture-only commit; the conformance check passes.

Risk and rollback

The risk is a conversation held when it should run. The hold never covers new input: a newer message, the card leaving a complete tray, a retry/hidden answer, or a restart ends it. A server that predates the route reads as none, so on such a server a failure with evidence now holds the conversation until a new message arrives, where before it ran again on every cycle. The server answers the route today. Rollback: revert this PR, or stay on 1.5.0. There is no wire, storage or server change.

…er message (1.5.1)

After a could-not-process report answered `none` or `paused`, the loop ran
the conversation again on its next cycle, on the same input, and it failed
the same way every time. The loop now holds it at the anchor it reported:
no cycle runs or gates it while its card shows that anchor (an `unanswered`
re-wake does not lift it), and a run or turn of it at that anchor does not
start, whether it waited for a slot or was decided before the answer came.
A newer message, or the card leaving a complete tray, ends the hold.

A failure reported on another conversation's completion now holds its
conversation until the answer, as one reported at its own end did: a freed
slot no longer starts it on the input the answer is about.

Status lists the held conversations; patch release 1.5.1.
…out for it

The runtime check's end woke the loop whenever a cycle had left any card
out. Inside a cycle, while a turn ran on, that made the gate spin: one gate
call and one runtime check per pass. The end of a report or check now wakes
only when a cycle left a card out because that card's report was out.
@sanctrl
sanctrl enabled auto-merge (squash) November 20, 2026 13:23
@sanctrl
sanctrl merged commit cfed17f into main Nov 20, 2026
4 checks passed
@sanctrl
sanctrl deleted the fix/hold-stuck-conversation branch November 20, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant