Skip to content

harness-backed Think onto the shared chat dispatch (H2c) - #3488

Draft
mattzcarey wants to merge 4 commits into
slim/chat-fn-6s1from
slim/harness-h2c
Draft

mattzcarey wants to merge 4 commits into
slim/chat-fn-6s1from
slim/harness-h2c

Conversation

@mattzcarey

Copy link
Copy Markdown
Member

The harness-backed Think takes a tab's chat frames through the shared chat dispatch (chatDispatch over ThinkHarness.chatDeps/chatLane), the same path AIChatAgent uses after #3361. Its turns frame their own replies. A connecting tab is offered a turn's stream through resumeChat. ThinkChat stays only for the transcript, clear and connect frames, and is unchanged for bare ThinkHarness hosts.

H2c of the Think closeout: the two Thinks get one chat protocol.

  • A run the dispatch submits is named by its request id, and its session comes from its input. Its ChatTurnInput becomes the harness's own operation: messages, regenerate, continue. A tab's copy of a stored message doesn't replace it.
  • A tab's client tools have one store. A request runs with the tools it sent; a continuation or a server turn runs with the chat's request context; a clear drops them.
  • A stop of a started turn goes to the harness, the one keeper of what it streamed. A request still waiting keeps its place on the dispatch.
  • The shell takes Think's messageConcurrency, waitUntilStable and hasPendingInteraction, and onChatResponse reports continuation.

Tests ran: harness-think (agents), and Think's suite on both configs. harness-compat is regenerated: 317 of 1296 on the harness config, against the 294 the switch's file records. The four rows not passing also fail on the switch's head.

Cost: a dispatch run's placement reads the chat's request context once and writes the session's client tools once. A turn reads its host's sockets per frame, and serializes nothing when no tab is connected. ThinkChat's broadcasts go through a per-connection proxy that drops the frames turns send themselves. No new rows, tables or KV keys.

The chat module's functions over Tasks, Streams, Sessions and WebSockets: chatDispatch, submitTurn, answerTool, cancelTurn, clearChat, resumeChat, replayTurn, and the chat-turn definition's parked tabs, live turns and stopped mark. Rebased onto main c519393 from e44a940; the one conflict (the turn's report) keeps main's stash drop and 6d's continuation and parked-tab steps.
…o main as one commit

AIChatAgent runs its turns on chatTurnDefinition and chatDispatch, and its old engine is deleted. Rebased onto the rebased #3298 from f87cd85 plus verify's FIX: main merged in (#3389, #3444, #3447, #3435, #3423 resolved in chat-host.ts with turn-task's notes), F27, the stop in a retry backoff ending the turn once, a throwing onChatRecovery given up with recovery_error, and turn-task's 25baf34.
@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 68cedb1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 4 packages
Name Type
agents Patch
@cloudflare/ai-chat Patch
@cloudflare/think Patch
@cloudflare/agent-think Patch

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

A tab's frames go through chatDispatch over ThinkHarness.chatDeps/chatLane; turns frame their own replies; a connecting tab is offered a stream through resumeChat; ThinkChat keeps the transcript, clear and connect frames. A dispatch run is the harness's own operation (messages, regenerate, continue), its session read from its input; a tab's list is reconciled against the stored transcript; a tab's client tools have one store (the request's, then the chat's request context; a clear drops them); a stop of a started turn goes to the harness's keeper; the shell takes messageConcurrency.
…blic successors); four pass on H2c and their rows are class-only, four wait for harness's reconciler
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