Skip to content

docs(chat): document terminal tools, idempotency, and the flush contract - #808

Merged
blove merged 1 commit into
mainfrom
blove/client-tools-docs
Aug 7, 2026
Merged

docs(chat): document terminal tools, idempotency, and the flush contract#808
blove merged 1 commit into
mainfrom
blove/client-tools-docs

Conversation

@blove

@blove blove commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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 lacking updateState silently got no durability with no warning anywhere.

Two audiences, two guides.

client-tools.mdx — app developers

  • Terminal tools with followUp: false — what they're for, and that follow-up is decided per tool-call group, not per tool.
  • idempotent and 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.
  • Stopping — stop cancels cleanly, records a cancelled result, and does not start a run. Documents the AbortSignal on the handler context with a fetch example.
  • Continuation limits — the 10-group default and [clientToolContinuationPolicy], including what happens to already-produced results when the cap trips.
  • A warning callout on the durability requirement: a terminal group has no follow-up run to carry its results, so a custom transport without updateState falls back to the next user message and loses them across a reload.
  • API reference extended with the options types and the three <chat> inputs.

writing-an-adapter.mdx — adapter authors

The guide previously said nothing about client tools. Adds the optional capability: the member table, selectPendingClientToolCalls for the pending predicate, 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:

  1. Take ownership of the batch when the write starts, not when it finishes.
  2. Coalesce concurrent flushes by chaining, not short-circuiting.
  3. Discard staged results on a thread switch — and note that a thread id captured at settle time may already be the new thread if setThreadId is synchronous.

Verification

  • nx build website succeeds.
  • nx lint website — 0 errors.
  • Every exported symbol named in the new API tables verified present in libs/chat/src/public-api.ts.
  • Handler-context example checked against the real FunctionToolDef signature rather than written from memory.

Docs only — no source changes.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
threadplane Ignored Ignored Aug 7, 2026 6:57pm

Request Review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval: this PR received an intelligent (AI) code review. See the review comments on this PR.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Claude finished @blove's task in 0s —— View job


I'll analyze this and get back to you.

@blove
blove merged commit 97a515c into main Aug 7, 2026
28 checks passed
@blove
blove deleted the blove/client-tools-docs branch August 7, 2026 19:04
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