Repository navigation
Conversation
Add ask() and createClientTools() to @threadplane/react/chat. An ask tool becomes a core function tool whose handler waits for the person; Chat, through the opt-in clientTools prop, shows the app-rendered view in place of the pending call, returns the answer as the tool result and moves focus back to the composer. MessageList gets the same through useClientToolCalls. No session or core contract change: a handler is not told its call ID, so a waiting call is paired with the transcript call by name and arguments.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ooking onto clientTools A waiting ask tool no longer replaces its call's row. MessageList gains renderToolCallPrompt, a control drawn below a message's tool calls, so the call stays in its group and the group's progress, Stop and plan remain visible. Chat wires clientTools through it, and useClientToolCalls now returns a prompt renderer. The LangGraph cockpit client-tools example declares confirm_booking with ask and createClientTools (src/booking.tsx) in place of its hand-rolled booking controller and approval-slot wiring.
The AG-UI client-tools example declares confirm_booking with ask and createClientTools (src/booking.tsx). The controller still checks the arguments and the running native call before the question is asked, and Stop or disposal revokes a waiting booking. Tokens, the booking snapshot and respond() are gone; Chat draws the card below the call through clientTools.
This branch was successfully deployed
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
React
Chatcan now show a tool the model calls and the person answers, the counterpart of the Angular chatclientToolsinput withasktools.ask()declares the tool;createClientTools()turns the declarations into coreFunctionTools whose handler waits for the person, and keeps the waiting calls.Chattakes the result as the opt-inclientToolsprop. While a call waits, the app's view is drawn below the message's tool calls. The call keeps its row and its place in the tool group, so the group's progress, Stop and plan stay visible. The value passed toanswerbecomes the tool result, the view goes, and focus returns to the composer. Stop aborts the waiting call.MessageListgainsrenderToolCallPrompt, a control drawn below a message's tool calls without replacing any of them.useClientToolCalls(clientTools)returns one for ask tools;usePendingClientToolCallslists what waits.confirm_bookingis anasktool insrc/booking.tsx, and the hand-rolled booking controller, decision tokens andapprovalslot wiring are gone. Its handler still checks arguments before the card shows, and disposal revokes a waiting booking.What already existed
Both framework-neutral sessions (LangGraph and AG-UI) already declare and run
FunctionToolhandlers, including async ones, with follow-up and an optional execution store. What React lacked was the chat side: a way to draw a pending call as an answerable control. The cockpit example hand-rolled this for bookings with an app-owned controller and theapprovalslot.Design notes
AgentSession,@threadplane/coreor either runtime. A handler receives only its arguments and an abort signal, not its call ID, so a waiting call is paired with the transcript call of the same name and equal arguments (else the oldest waiting call of that name). Identical calls are interchangeable, and a view always answers the arguments it was drawn with.clientToolsis set; no default changed.verify-packagesallow-lists the four new runtime exports ofreact/chat.Left for later
viewtools (today: a plain function tool plusrenderToolCall).renderunvalidated.clientToolContinuationPolicy).usePendingClientToolCalls.apps/website/public/media/docs/tools-react-capture.jsonrecords hashes of the example source from the last video capture; the demo video was not re-captured.ExecutionContextchange and was not made here.Verification
npx nx run-many -t test,type-tests,lint,build -p react,content,core: passed.npx nx run-many -t test,lint -p cockpit-langgraph-client-tools-react,cockpit-registry: passed.npx nx e2e cockpit-langgraph-client-tools-react: passed. This builds the isolated consumer with strict type checks and drives the example in Chromium against the local LangGraph fixture over real SDK HTTP and SSE: parallel identical bookings, focus, records, Stop, and the Trip group's progress and plan while the booking waits.node scripts/react-parity/verify-packages.mjs: passed.node scripts/react-parity/inventory.mjs --check --drift warn: valid (baseline drift is informational).node --test scripts/react-parity/{verify-packages,runtime-consumer,inventory}.spec.mjs: 169 passed.client-tools.spec.tsx(14 specs), each red, restored tree green: prompt not rendered byMessageList; and, from the first commit, no focus return, renderer not refreshed when a call starts waiting, no argument pairing, abort ignored.apps/website/e2e/react-client-tools-preview.spec.tswas not run locally.AG-UI cockpit example
The AG-UI client-tools example (
cockpit/ag-ui/client-tools/react) now declaresconfirm_bookingwithaskandcreateClientToolstoo (src/booking.tsx). Its controller keeps the check of the arguments and of the single running native call before the question is asked, and Stop, New conversation or unmount revokes a waiting booking. The decision tokens, the booking snapshot andrespond()are removed, along with the re-check of the native call at answer time: the card is only drawn whileChatsees the call running.Verified: example test (102) and lint,
cockpit-registrytest and lint,nx e2e cockpit-ag-ui-client-tools-react(25 passed, Chromium, local fixture), website suite (1988), cockpit script specs (50). Mutation check: without the disposal signal and the asked-once record, three specs fail.🤖 Generated with Claude Code