Repository navigation
Chat turns: a completed reply that ends in reasoning is kept; the reasoning is left out of the model request (F21) - #3487
mattzcarey wants to merge 7 commits into
Conversation
|
| 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
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
🟢 agents import sizes: 1 entry point changed, no growth
Changed exports (1)
How this worksEach runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement. Compared |
b2f743b to
038c38c
Compare
95b4364 to
fd94e8f
Compare
038c38c to
f903bf4
Compare
… next question (F21, fails on main)
…reasoning (a reply may complete that way); Think leaves that reasoning out of the model request only (F21)
…nscript, left out of the model request (F21)
…m messages without the reasoning a stored reply ends in; docs (client-tools-continuation, chat-turn-core D51/D57) and the changeset line
…ll.messages (the harness-backed Think's request too) and the stored list as .transcript; AIChatAgent gives its app the transcript, no swap
…soning-only reply as two tests, and that a reply cut off in its reasoning leaves none before the next question; client-tools checks the continuation's answer follows
…host) does not load the Lifecycle: the node chat tests import chat-turns -> chat-host again
5ce4550 to
578ed54
Compare
|
Replaced by #3504, which carries this change with the rest of the switch (integrated and tested together). |
A reply that ended with reasoning only (some models finish that way,
finish: "stop") disappeared from the transcript at the next turn. The before-turn repair stripped trailing reasoning in storage and then deleted the message it had emptied. That was the missing assistant message in the deployed soak (F21). Matt's rule (b) replaces it: a reply that completed is kept as stored, and its trailing reasoning is left out of the model request only. A reply cut off while reasoning is still removed by recovery, as before.before-turn.ts,repair-transcript.ts,chat-turns.ts): the before-turn repair no longer strips reasoning in storage (stripReasoning: false), so a reply that holds only reasoning is no longer "empty".requestMessages()builds the request view: each message without the reasoning it ends in, and without the messages that leaves empty. Replies that hold nothing at all are still removed.settleBeforeTurn's returned messages).this.messagesis that view whileonChatMessagebuilds its request, then the transcript again.settleInterruptedReply,removeEmptyReplyToContinue,replyIsEmpty). A reply cut off in its reasoning, or onecontinueLastTurn()or a recovery would continue, is still removed and the question answered again.Stacked on the switch group (#3298 + #3361 + #3475) and merges after it.
Cost
No extra statement. The repair writes less: it no longer rewrites or deletes a reply that ends in reasoning. Building the request view is one pass over the messages in memory.
How to probe
packages/think:empty-reply.test.ts"keeps a completed reply that holds only reasoning when a new question comes". The reply is still stored, and the next model prompt has no assistant message. It fails with the switch's chat files (b2f743b).packages/ai-chat:chat-turn-races.test.ts. The reasoning-only reply is kept and no tab is sent a list without it, andgetEndsInReasoningAtModelCallForTest()is empty, so the request is valid for Anthropic. The ai-chat suite passes 829/829. Chat unit tests pass 1472/1472 and chat-host 186/186.