Skip to content

Settle every failed hosted move and derive thread attention once - #1001

Merged
max-sixty merged 2 commits into
mainfrom
obligation-model-leftovers
Sep 23, 2026
Merged

max-sixty merged 2 commits into
mainfrom
obligation-model-leftovers

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

#983 made every agent obligation one workflow answer and listed four things it left undone. This PR finishes them.

A failed hosted turn settles every move it was given

Before this PR, a hosted turn that failed wrote a failure receipt only for moves owed a reply. A request, an answer to a page Ask, or a conversation that asked for a version stayed owed with no turn coming for it.

conversation.fail_answer is now the single writer the worker calls, and it writes whatever failure the move's answer calls for:

  • reply, version: a reply carrying failure in the conversation. cmd_reply now accepts a host failure receipt in a version thread, because a failure reply is the only reply that thread can take.
  • receipt: a failed receipt. That is the request's own terminal outcome, so its seat reopens and the reader can press it again.
  • markup: a pickup with the new phase failed and a failure code. The reader's Ask answer stays in the log. The workflow reads answered, with a failed response, and its next actor is the reader until they answer again or the markup records the answer.

HostedTurn._receipt_unanswered now covers every owed move in the delivery (codex.delivery_owed_moves), not only replies. The worker door and the continuation scan already went through write_failure_receipt, so they get the same dispatch. The host failure wording no longer says "message", since a request can now carry it.

Thread attention is derived once

Python's _apply_thread_attention is the only place thread attention is derived. The browser no longer has projectThreadAttention or the browser-only next_actor: "none". It changes the server's attention only for unresolved local sends:

  • a pending send makes its thread wait on that send (foldThreads)
  • a standing reader Ask survives prose sent beside it (publisher, as before)
  • a refused send gives a thread the server left with the agent back to the reader, with reason recovery

One name for the subject

Workflow subjects and coordinates, update targets, and status --on claims now all use {"kind": "conversation"}, the name delivery, page state and the CLI already used. agent_state's translation layer is removed. The document kind {"kind": "thread"} for frozen thread markup is a different concept and keeps its name. The thread field on Asks is also unchanged.

The working grace is served once

served_state/page.py now serves working_grace_ms from activity.WORKING_GRACE alongside now. presence.quietSince reads that value, so its 15-minute copy is gone. Nothing reads as quiet until a state has arrived.

Behavior that moved

  • While a send is pending, its thread waits on that send, even if the server has a stronger workflow such as a live reply. This lasts until the log answers the send.
  • A refused send's attention reason is recovery. It was workflow.
  • quietSince uses >=, the same comparison Python's _quiet uses. Its grace argument is removed.

Tests

  • New: test_a_failed_turn_hands_every_kind_of_owed_move_back, parametrized over markup, receipt and version. A turn that completes without answering must leave no obligations and nothing for the continuation scan to pick up, and each move must end up in the shape its answer takes. With the sweep limited to replies, all three cases fail.
  • test_a_host_receipt_does_not_answer_input_an_agent_turn_already_claimed goes through write_failure_receipt.
  • The runtime and publisher tests that asserted the old JS attention re-derivation now assert that local sends adjust the server's attention.
  • Subject kinds in fixtures are renamed.

Local runs: tests/test_website_server.py, the five test_interact_* files touched, npm run test:runtime, the browser gate (check:browser, test:browser) and pre-commit all pass. A keyword selection over the render suites passed except two cases, test_a_growing_reply_keeps_its_send_in_the_list and test_unit_claim_arrivals_share_one_window_with_the_open_page_map. Both also fail locally on the base commit 19a0213.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

Finishes the obligation model from #983.

- A failed hosted turn now settles or returns every move it was given, by the
  answer the move owes. `conversation.fail_answer` is the one writer: a message,
  or a conversation that asked for a version, gets a reply carrying `failure`; a
  request gets a failed receipt, which reopens its seat; an answer to a page Ask
  gets a failed `pickup`, a new phase that hands the move back to the reader
  (workflow answered, failed response, next actor reader) until they answer
  again or the markup records it. The worker's `_receipt_unanswered` sweeps every
  owed move in the delivery, not only replies.
- Thread attention is derived only in Python. The browser drops
  `projectThreadAttention` and the browser-only `next_actor: "none"`; it adjusts
  the server's attention for unresolved local sends alone: a pending send waits on
  that send, a standing reader Ask survives prose, a refused send returns a
  thread the server left with the agent to the reader.
- Workflow subjects, coordinates, update targets and work claims name a
  conversation `{"kind": "conversation"}` everywhere, as delivery and the CLI
  already did; `agent_state`'s translation is gone.
- The working grace is served once, as `working_grace_ms` beside `now`;
  `quietSince` reads it instead of its own 15-minute copy.

Behavior that moved: a thread holding a pending send waits on that send rather
than on the strongest server workflow; a refused send's recovery reason is
`recovery`; host failure wording no longer says "message", since a request can
carry it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skills/leaf/scripts/leaf/events.md and worker/README.md both now say the host records failure on whichever failure the move's answer takes, and name a failed receipt as one of the three. A receipt can't carry it: _fail_page_answer's receipt branch writes no code, and the registry's receipt record is additionalProperties: false with no failure property.

Nothing reads the code for a request today — canonical_workflows discriminates replies by response.get("failure") and pickups by phase — so this is the references overstating rather than a broken path. What it hides is worth naming, though: conversation/messages.js draws the "answers nothing" head off message.failure, so the reply and pickup arms are marked as standing in for an answer and the request arm isn't. A host give-up receipt reads as the agent having tried and failed, which the FAILURE_RECEIPTS comment calls "the failure this whole path exists to make visible".

The suggestions correct the prose, which leaves the receipt arm as easy to extend as it found it. Adding failure to the receipt record and writing it in that branch is the other way, if the asymmetry is the half worth moving.

Comment thread skills/leaf/scripts/leaf/events.md Resolved
Comment thread worker/README.md Resolved
A failed request receipt has no field for `failure`; events.md and the
worker README said every shape carried it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 127ad14 into main Sep 23, 2026
5 checks passed
@max-sixty
max-sixty deleted the obligation-model-leftovers branch September 23, 2026 11:16
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.

2 participants