docs(chat): document terminal tools, idempotency, and the flush contract - #808
Merged
Conversation
Client-tools guide gains app-facing docs for followUp:false terminal tools, idempotent + the execution guard, AbortSignal on handlers, and the continuation-turn cap — none of which were documented after #807. Adapter guide gains the settle/flush/resolve contract, the invariant it protects, and the three implementation rules each learned from a real defect (batch ownership at snapshot, chain don't short-circuit, discard staged results on thread switch). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
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.
Summary
Documents the client-tool surface added in #807. That PR shipped
flush(),followUp,idempotent, the continuation policy, and the execution guard — all public API, none of it documented. Terminal tools were undiscoverable, and a custom transport lackingupdateStatesilently got no durability with no warning anywhere.Two audiences, two guides.
client-tools.mdx— app developersfollowUp: false— what they're for, and that follow-up is decided per tool-call group, not per tool.idempotentand the execution guard — non-idempotent by default; when to opt out. Includes the honest limit: the guard gives at-most-once dispatch, not exactly-once effects, so a handler with real side effects should pass its own idempotency key downstream.AbortSignalon the handler context with afetchexample.[clientToolContinuationPolicy], including what happens to already-produced results when the cap trips.updateStatefalls back to the next user message and loses them across a reload.<chat>inputs.writing-an-adapter.mdx— adapter authorsThe guide previously said nothing about client tools. Adds the optional capability: the member table,
selectPendingClientToolCallsfor thependingpredicate, and the invariant it exists to protect — the server thread must never hold a client tool call without a corresponding tool result.Also documents why
resolve()alone cannot uphold that (terminal groups, stop, continuation limits never continue), and three implementation rules, each of which came from a defect found during #807's review:setThreadIdis synchronous.Verification
nx build websitesucceeds.nx lint website— 0 errors.libs/chat/src/public-api.ts.FunctionToolDefsignature rather than written from memory.Docs only — no source changes.
🤖 Generated with Claude Code