Skip to content

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

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. An action this release does not know is read as none, as the TypeScript client reads it.
  • A reply turn of it at that anchor does not start. One waiting for a slot is dropped (after paused, any). One decided before the answer came is checked again when it starts. A turn 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.

Gate-call mode: a failed turn waiting for evidence that another turn's end reports on is now held from that end until the settle is done. No cycle gates it meanwhile, and a turn of it waits for the answer, including one launched with a slot free. Before this, the freed slot could start it on the input the answer was about.

Status:

  • status().held_after_failure lists conversation_id, anchor, since and reason, so integrations' status/doctor can say "not retried until a new message arrives".
  • counters["starts_held"] counts the turns not started because of a hold.
  • CycleSummary.held_after_failure counts the cards a cycle left out.

The new fields have defaults. Existing fields are unchanged.

Version 1.5.1 in pyproject.toml and _version.py (a patch: it fixes existing behaviour, per VERSIONING.md), with a CHANGELOG section ## [1.5.1] — 2026-11-20. The README is updated. No tag is created here: publishing is the separate, approved release step.

Verification

  • Tests: ruff check src tests clean; mypy clean; pytest 1084 passed, 2 skipped on Python 3.9 and again on 3.10 (15 new could-not-process tests); 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 over the socket while the other conversations keep running, with a newer message lifting the hold and the next failure getting retry; a waiting turn 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 gate-call start-time races; a newer-anchor turn kept on none and dropped on paused; a silent turn under way not lifting the hold; an invite turn's end; report errors holding nothing; 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 turn started, so a reply decided before the answer came, or launched while the report was out, could start on the held input. It also raised a pace replacing a hold at the same anchor, a head-of-line delay, and status and doc inaccuracies. All are fixed and covered by the new tests; the reviewer's repro scripts now show the conversation staying held. A re-review of the fixes found no issues (one summary count not incremented for a card skipped in the one-card-per-call gate, which is by design: that card was already gated and counted in that cycle). The TypeScript twin's re-review found a wake that could spin while a turn runs; Python never had it (its settle ends only at a turn's end), but it now uses the same rule: a settle's end wakes only for a card a cycle left out because its report was out (a no-spin test pins it).
  • 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 answers 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.
@sanctrl
sanctrl enabled auto-merge (squash) November 20, 2026 13:17
…or its report

The end of a settle read the tray again whenever a cycle had left any card
out (a running turn's included). It now wakes only when a cycle left a card
out because that card's report was out, so it can never become a wake for
cards a running turn holds.
@sanctrl
sanctrl merged commit 386879b into main Nov 20, 2026
12 of 13 checks passed
@sanctrl
sanctrl deleted the fix/hold-stuck-conversation branch November 20, 2026 13:25
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