Repository navigation
Client tools and conversation scope for app clients (agents.tools_set, agents.set_scope) - #2613
Merged
Merged
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]>
…wer cutoff is a wait Carries #2346 (b1a02be) and #2360 (25c6faa) from workstreams/main. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
Carries #2417 (08b6e1e) from workstreams/main. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
Carries #2462 (e985a44) from workstreams/main. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
Replaces the five entries carried with the source commits. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
AbirAbbas
marked this pull request as ready for review
November 12, 2026 19:25
…rovider 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]>
… 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]>
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]>
AbirAbbas
added a commit
that referenced
this pull request
Nov 13, 2026
Brings in #2613, #2612, #2614, #2618 and #2615. #2618 changes the visibility check this branch's job-events cursor reads: a spent GitHub rate limit returns GitHub's retry time instead of a cached denial, and is remembered per token until then. The two meet in repoAllowed, which this branch made answer (allow, known). A remembered limit answers false, false: a limit says nothing about the repository, so the job-events page ends before it as before any undecided one, as a fresh limit already does (askRepo's cache=false). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
The desktop app now owns Workstreams: its store, pages, sources and the workstream agent's tools all live in codeaf-desk. The one thing the desk cannot do for itself is make the model call those tools, because the engine runs the model loop. This PR gives
codeaf appthe two generic pieces the desk needs for that, and nothing that knows what a workstream is.It carries #2334, #2346, #2360, #2417 and #2462 from the closed integration PR #2306 (
workstreams/main) ontodev. That PR could not merge: its base,app/v3, landed ondevin #2561 and #2597 left it out as unfinished.Wire surface added
agents.client_tools,agents.client_tools.sourceagents.client_tools.remoteagents.scopeagents.tools_set {agent, set, instructions?, deadline_ms?, tools[]}{agent, set, tools}agents.tool_result {call, result | error}{accepted}agents.set_scope {id, scope}project(default) orconversation; answers{id, scope}agents.tool_call {agent, turn, call, turn_call, source_message_id?, set, name, args, deadline_ms}Limits: 4 sets and 64 tools per conversation, 32 tools per set, wait of 30 s by default and 1–120 s when given. A disconnect, the wait or the end of the turn answers the model with an error saying the outcome is unknown. Built-in tool names are refused and child tasks never receive client tools. The remote protocol version is unchanged; a holder from an older build still answers
bad_scope.docs/design/app-v3/PROTOCOL.md,docs/REMOTE.mdand the chat manual (internal/manual/chat/client-tools.md, the scope section oftasks.md) are updated in the same change.What was left out
Config.Workstream,workstreamWithoutPage,appWorkstreamAgents,v3WorkstreamKeeps); none of it is here.git grep -i workstreamfinds nothing in the files this PR adds.devalready has it from A blank conversation a collection holds is kept, never resumed, and shown as live #2475, sodev's sweep and launch cleanup are untouched.collections.factory_job(App wire: announce collections.factory_job when collections hold Factory jobs #2468) and the Factory additions from Generic collections (factory_job refs) and client tools (integration branch; draft, do not merge) #2306. They are separate work.How it was carried
Four commits, one per source change (#2346 and #2360 together), cherry-picked in order. Conflicts were in
cmd/codeaf/app.go,cmd/codeaf/engine.go,internal/session/{inherit,questionconversation,session,sweep}.go,cmd/codeaf/chatv3_layout.goandinternal/remote/{client,server}.go; each was resolved by keepingdev's side and adding only the client-tools lines. The 17 files this feature owns are byte-identical to their final state onworkstreams/main(631c78a), and the per-file count of client-tool and scope identifiers matches that branch in all 49 files that mention them.Checks
CI on 9c839e8: the required
check, light gate, touched codeaf, touched rest, touched session and windows native tests all pass.Built engine, no provider key (
bin/codeaf app --home <scratch>): the hello listsagents.client_tools,agents.client_tools.source,agents.client_tools.remoteandagents.scope.agents.tools_setandagents.set_scopefor an unknown conversation answernot_found, a bad scope answersbad_params, andagents.tool_resultfor an unknown call answers{"accepted": false}; none answersunknown_method.Local, macOS arm64:
make test-quickgo test -count=1 ./internal/appwire ./internal/remoteinternal/session/{client_tools,scope}_test.gocmd/codeaf/{appclienttools,appclienttools_remote,appscope}_test.gomake pr-readymake test-remotemake pr-readypassed its light gate and theinternal/appwireandinternal/remotelegs. Thecmd/codeafleg (8 shards) reported 15 failing tests, none in a file this PR touches. Run alone afterwards:dev(ffeeb78) on this Mac:TestAppFactoryPlanFilesAnswer,TestFactoryCommandStepRetryAfterOutOfAttempts,TestFactoryMeasuredOnlyPublication,TestFactoryRetryActionsDoNotReportStopped,TestFactoryStepRetryWaitsForPreviousLeaseCleanup,TestFactoryWriteUsesJobBaseAcrossAttempts,TestMemoryPauseResumeAfterTrailingProgress,TestMemoryPauseRetainsPendingForResume,TestMemoryPausedJobLifecycle.TestC7R2ReopeningChatStopsPreviousDrive,TestDoctorFindsAndRepairsSyncAndEngineStoreSafely(3 of 3 after one failure),TestFactoryVerificationThroughTheRealStageConversation,TestHostedTakeBackReachesAcquireWithoutSharedUploadsOrReleaseDelay,TestProcessCloseJoinsTheUsageWriter.TestFactoryPersonStopInFlightWakeAndPersonChat/queued_personis intermittent on both trees here: 6 of 9 runs failed on this branch and 4 of 8 ondev, with the machine's load average between 30 and 40 from other suites.The
internal/sessionleg, run separately once the machine's suite lock was free (make test PKGS=./internal/session SHARDS=8 TEST_FLAGS='-count=1 -p 2'), reported 5 failing tests:TestACommandLookFailsOnAFailingPipeStage,TestBashBeltTruncationCapFollowsTheWindow,TestBashBeltTruncationWritesHeadTailAndPath,TestTheFixedPrefixStaysUnderItsBudget,TestWatchTickFailsOnAFailingPipeStage. All five fail with the same messages on unmodifieddevon this Mac (exit status 141 from macOS bash 3.2 pipes; the fixed prefix reads 52502 bytes against a 52497 budget on both trees, so this change adds nothing to it).So every local red is either red on
devon this Mac or intermittent on both trees, and the same selector is green in CI. The localmake pr-readytherefore did not pass as a whole on this Mac; the PR is marked ready on the strength of CI and the comparison withdevabove.Changes after review
Three commits on top of 9c839e8 address the review. Every new test below failed before its fix and passes after it.
1. A client tool call's id now covers the whole call (f190820)
callid sent to the app was built only from the conversation and the provider's tool-call id, so a provider that reused an id for another tool or other arguments (Kimi'sname:indexids, rewind or compaction, a faulty server) got the earlier call's saved answer or joined its wait without the app ever seeing the new call, and a call with no provider id gotct_fresh_Nfrom a counter that restarted at every launch, so the desk's 30-day answer table could replay an old answer after a restart; the remote holder path had the same defect.clientToolCallIDincmd/codeaf/appclienttools.gonow hashes the agent, provider call id, set, tool name and exact argument bytes, each length-prefixed, and keeps thect_+ 64-hex shape. A call with no provider id gets a randomct_id fromcrypto/rand, and the counter is removed. A true redispatch of the same call still gets the same id and the saved answer. Thecallparagraph inPROTOCOL.mdand the change entry are updated.TestClientToolsReusedProviderIDWithAnotherCallReachesTheApp(settled and pending subtests),TestClientToolsCallWithoutProviderIDNeverRepeatsAcrossLaunches(two separate engine launches),TestClientToolsRemoteReusedProviderIDWithOtherArgumentsIsANewCall, and an extendedTestClientToolsSettledMemoryBoundAndExpiry. The existing replay and pending-join tests still pass unchanged.2. Under conversation scope, the prompt and the
taskstool no longer promise other windows' work (5e5efce)conversationscope the engine already hid other windows' work from the<elsewhere>note and from task search, but the system prompt still said "OTHER codeaf WINDOWS ON THIS PROJECT ARE VISIBLE TO YOU" and thetaskstool description still said search includes other windows' live work, so the model was promised information it would never get.tasksdescription now follow the stored scope. Under conversation scope they say other windows' landed files and running work are hidden, so the model must not conclude that nothing else is running. A scope change applies from the next turn start in either direction, including to ataskstool loaded later from the lean shelf. It costs one cold prompt prefix, like a placement change. The project-scope page and tools are byte-identical to before; the fixed prefix still measures 52502 bytes.internal/session/prompts/system.mdkeeps its project-scope line, and the conversation variant is swapped in at render time frominternal/session/scope.go.PROTOCOL.md,internal/manual/chat/tasks.mdand the change entry are updated.TestConversationScopeShapesWhatThePageAndTasksToolPromisechecks the request the model actually receives through project, then conversation, then project again, then a reopened conversation-scope chat.TestConversationScopeReachesAShelvedTasksToolcovers the lean profile.3. Evaluated and fixed: a remote session swap drops the old conversation's tool sets (3ded075)
ClientToolHubserves the session acrossSession.NewandSession.Openswaps and the swap never cleared it, so the replacement conversation inherited the joined app's tool sets, its calls went to the app under the old conversation id, and the app's answer was refused, leaving the model withclient_timeouteven though the app may already have acted.Session.swap(internal/remote/server.go) now calls a newClientToolHub.forgetbefore the new agent can be reached.forgetdrops every set and ends each pending call with a "turn ended" answer and aclientToolEndedframe, so the app stops waiting. It also makes the hub refuse later snapshots, withErrJoinedGone, from a joined connection still on the old conversation. A following window can still attach to the new conversation.PROTOCOL.md,docs/REMOTE.md,internal/manual/chat/client-tools.mdand the change entry are updated.TestClientToolsRemoteSessionSwapDropsTheOldConversationsSets(new and open subtests) checks that the hub is empty after the swap. It also checks that a call from the replacement answersclient_unavailablewithout reaching the app, that the pending call ends and cancels the app handler, and that the old joined connection's snapshot is refused. The otherTestClientToolsRemote*tests and the existing swap and join tests pass under-race.All three review items were fixed. None was left unchanged.
🤖 Generated with Claude Code