Skip to content

Client tools name their answer cutoff a wait, so the leaf-room law passes - #2360

Merged
AbirAbbas merged 2 commits into
workstreams/mainfrom
workstreams/cleanup-subharness
Nov 4, 2026
Merged

AbirAbbas merged 2 commits into
workstreams/mainfrom
workstreams/cleanup-subharness

Conversation

@AbirAbbas

Copy link
Copy Markdown
Collaborator

Summary

internal/exec TestOnlyTheSubharnessTableSizesALeafsRoom has been red on workstreams/main since client tools (#2334). It flags cmd/codeaf/appclienttools.go:375, where a pending client-tool call stores the instant the engine stops waiting for the client's answer in a field named deadline, sized from milliseconds.

That value isn't a leaf's room. It comes from the client's registered tool set (set.DeadlineMS), or from the call's own DeadlineMS when that falls between ClientToolMinDeadlineMS and ClientToolMaxDeadlineMS. Routing it through exec.SubharnessFor(name).Deadline(tokens) would replace the client's limit with a token-sized one. The law has its own guidance for this case ("an instant a poll loop gives up at is not a room; naming it so is the fix, not an exception"), and #2229 followed it for job search's bound. This PR does the same:

  • clientToolPending.deadline becomes answerBy.
  • The local limit in beginLocked becomes waitMS.
  • The one test that sets the field is renamed to match.

The law test is untouched.

Validation contract

Behaviour Covered by
The leaf-room law passes: nothing in cmd/codeaf/appclienttools.go sizes a room TestOnlyTheSubharnessTableSizesALeafsRoom
Client-tool calls keep the same effective time limit: same source, same DeadlineMS sent to the client, same wait timer, same expiry checks Existing cmd/codeaf/appclienttools_test.go (only the field rename applied), for example TestClientToolsEndedQueuedCallsAreNotEmitted
No other law turns red Laws and touched-package legs, compared with the workstreams/main baseline below

Baseline

These reds are already on workstreams/main at 4d6562c69 (PR gate 41872030719). They're inherited from app/v3 and not touched here:

  • TestNoRoadInTheMemoryEngineHasMoreEndingsThanTheCeiling
  • TestNoRoadInTheTaskEngineHasMoreEndingsThanItsLedgerRow
  • TestALandStartsNoAutomaticMaintenance
  • TestProgramHoldClassifiesEveryRegisteredChatTool
  • TestTheFixedPrefixStaysUnderItsBudget and TestTheLeanPrefixStaysUnderItsBudget
  • The guard lock law on cmd/codeaf/app_move.go:135

This PR should remove TestOnlyTheSubharnessTableSizesALeafsRoom from that list and add nothing.

🤖 Generated with Claude Code

AbirAbbas and others added 2 commits November 4, 2026 13:03
The pending client-tool call held the instant the engine stops waiting for
the client's answer in a field named `deadline`, sized from milliseconds.
The leaf-room law in internal/exec reads any such write as a hand-sized
leaf room and failed on it. It is not one: the limit comes from the
client's registered tool set (or the call's own in-range DeadlineMS), not
from the subharness table, and routing it through SubharnessFor would
change it.

Rename the field to `answerBy` and the local limit to `waitMS`. The
effective limit, the DeadlineMS sent to the client, the wait timer and the
expiry checks are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas
AbirAbbas force-pushed the workstreams/cleanup-subharness branch from 9e8c43d to d20df54 Compare November 4, 2026 18:07
@AbirAbbas
AbirAbbas merged commit 25c6faa into workstreams/main Nov 4, 2026
4 of 6 checks passed
@AbirAbbas
AbirAbbas deleted the workstreams/cleanup-subharness branch November 4, 2026 18:36
AbirAbbas added a commit that referenced this pull request Nov 13, 2026
…, agents.set_scope) (#2613)

* Client tools: a client attaches tools to a conversation

Carries #2334 from workstreams/main (e9a571c) onto dev. The workstream
door that commit sat beside is left out, and the collection-held
conversation half is already on dev (#2475).

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* Client tools: a tool call names the message its turn answers; the answer cutoff is a wait

Carries #2346 (b1a02be) and #2360 (25c6faa) from workstreams/main.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* Client tools cross the remote door to the connection that set them

Carries #2417 (08b6e1e) from workstreams/main.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* A conversation can be told only about its own work (agents.set_scope)

Carries #2462 (e985a44) from workstreams/main.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* changes: one entry for client tools and conversation scope (#2613)

Replaces the five entries carried with the source commits.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>

* Client tools: a call id hashes the whole call, and a call without a provider id gets a random id

The `call` id was sha256(agent, provider call id), with a per-process
counter when the provider gave no id. Provider ids are not unique:
Kimi-family models write their own `name:idx` ids, which repeat after
agents.rewind or compaction, and a faulty server can repeat any id. A
reused id with another tool or other arguments therefore joined the
earlier call's wait or got its saved answer, and never reached the app,
while the app's 30-day table replayed the old answer for the same id.
The counter restarted at every launch, so ids minted without a provider
id came back after a restart.

clientToolCallID now hashes the agent, provider call id, set, tool name
and exact argument bytes, each length-prefixed, and keeps the `ct_` + 64
hex shape. The same call dispatched again keeps its id, joins the pending
wait and gets the saved answer. Without a provider id the id is 32 random
bytes. Calls from a remote holder reach the same door, so they share the
identity.

PROTOCOL.md and the change entry say what `call` is derived from.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Conversation scope: the page and the tasks description stop promising other windows' work

Under `conversation` scope a conversation gets no <elsewhere> block and
its tasks tool lists only its own work, but its system prompt still said
"OTHER codeaf WINDOWS ON THIS PROJECT ARE VISIBLE TO YOU" and the tasks
description still said search includes other windows' live work. The
model could read an empty answer as "nothing else is running here" and
tell the person so.

The page's other-windows line and the tasks description now follow the
stored scope. Under conversation scope the page says the conversation is
told only about its own work and must not conclude nothing else is
running; the tasks description says search reaches only its own work,
even with scope everywhere. A project page and tasks description stay
byte for byte as before.

The scope is read when the agent is made and again at each turn's start.
A changed scope re-renders the page and replaces the tasks tool on the
belt and on a lean shelf, in fresh arrays, so the model sees the change
from the next turn, as the scope already promises. Task nodes keep their
page.

PROTOCOL.md, the tasks manual page and the change entry say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Client tools: a session swap drops the old conversation's sets

A holder shares one ClientToolHub across the initial, fresh and resumed
openings of a remote Session. When another window ran /new or /resume,
Session.swap replaced the agent but left every connection's sets in the
hub, so the replacement conversation got a joined app's tools and
instructions, and its calls went to that app under the old agent's id.
The app then wrote into the old workstream, and its answer was refused
with ErrJoinedGone, so the holder's model was told client_timeout.

Session.swap now calls ClientToolHub.forget before the new agent is
reachable: every connection's sets go, pending calls end with a
clientToolEnded frame so the app stops waiting too, and a joined
connection's snapshot that was already past the session's check is
refused. A following surface may still attach to the open conversation.

PROTOCOL.md, REMOTE.md, the client-tools manual page and the change
entry say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Mythos 5.2 <[email protected]>
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