Skip to content

Client tools: a tool call names the message its turn answers - #2346

Merged
AbirAbbas merged 4 commits into
workstreams/mainfrom
workstreams/source
Nov 4, 2026
Merged

AbirAbbas merged 4 commits into
workstreams/mainfrom
workstreams/source

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A client that attaches tools could not tell which message caused a tool call: agents.tool_call carried turn (the app's process-local counter, which resets when the engine restarts, and which the door sampled at call time, so a woken turn could report an older one) and turn_call (the provider's call id). Neither names a message.

  • agents.tool_call gains optional source_message_id: the durable id of the message the running turn answers, the same string as Entry.message_id on that message's chat entry (agents.read). Omitted when no such message exists; older clients ignore it.
  • New hello feature agents.client_tools.source, advertised exactly with agents.client_tools, so an absent field means "no message", not "older engine".
  • The id is captured once when the turn starts (a separate turnOrigin.answers beside the crew opener, whose behaviour is unchanged) and read from the call's context; it is never sampled from app state.
    • a person's message through any door, including queued follow-ups and another connection: that message;
    • a stopped turn asked again (ResumeStoppedTurn): the recorded line's id;
    • a woken turn answering the person's single drained line: that line;
    • turns the engine starts itself (task/job/watch landings, crew notes, settle wakes, a carry-on after a quit or close): none. Errands run no tools.
    • A steer or note landing mid-turn never changes it.
  • docs/design/app-v3/PROTOCOL.md documents the field, the feature and that turn is process-local.

Part of the Workstreams plan (proposal sources). Generic: any client that attaches tools can link a call to its message.

Validation contract

  • (a) a call made while answering M carries M's id (and M2's calls carry M2's): TestClientToolsSourceMessageWireAndRestart (real session, scripted provider, app registry; compared with the transcript read), TestClientToolsSourceSubmissionDoors, TestClientToolsExecuteSourceMessage.
  • (b) the same id after an engine restart and on replay: TestClientToolsSourceMessageWireAndRestart (journal reopened in a fresh session/backend), TestClientToolsSourceStoppedTurnReplay, TestClientToolsSourceLegacyStoppedTurn, TestClientToolsSourceCarryOnReplay (a carry-on names none), TestClientToolsEventResultAndReplay (fresh registry: same call id and source), TestClientToolsPendingJoinAndCancelledAnswer.
  • (c) woken turns: a note-woken turn after M carries none (never M), a wake answering one drained line carries that line: TestClientToolsSourceWakes; errands and children stay tool-less: TestClientToolsDoNotTravelToChildren.
  • (d) absent only when no message exists, never wrong: TestClientToolCallSourceMessageJSON, TestClientToolsSourceSurvivesSteering, TestClientToolsHelloFeature, TestTheSchemaIsGeneratedForTheWholeWire, TestClientToolsSourceProtocol.

🤖 Generated with Claude Code

AbirAbbas and others added 4 commits November 4, 2026 09:12
…message_id)

agents.tool_call gains an optional source_message_id: the durable id of
the message the running turn answers, the same string as Entry.message_id
on that message's chat entry. It is captured when the turn starts and
carried on the turn's context, never sampled from the app's current turn,
so it survives an engine restart and a replayed call. A stopped turn asked
again carries its recorded message; a carry-on after a quit or close carries
the message that opened the interrupted run only when the record names it
exactly. Turns the engine wakes on its own notes carry none. Crew
provenance is unchanged. The hello feature agents.client_tools.source
comes with agents.client_tools; turn stays the process-local counter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A call names its own message (and a later message its own), the same id
after reopening the journal, on a resumed stopped turn, on an exact
carry-on and on a fresh-registry redispatch; note-woken turns carry none;
a steer never moves it; the field is omitted when empty and the feature
rides with client tools. Every wait in the new fixtures is bounded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Naming the interrupted run's opening message needed a run id on the
person's line, which changes what a person's line records. A carry-on
turn is one the engine starts itself, so it now carries no
source_message_id, like every other turn the engine starts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas
AbirAbbas merged commit b1a02be into workstreams/main Nov 4, 2026
4 of 8 checks passed
@AbirAbbas
AbirAbbas deleted the workstreams/source branch November 4, 2026 14:57
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