Skip to content

Commit 0843a07

Browse files
committed
feat(tools): add send_user_message for models that summarize text between tool calls
On Opus 5.5, Fable 5/5.1 and Mythos 5.1, the text the model writes between tool calls comes back from the API only as a short summary, under every thinking.display value. Links, paths and numbers the model put there for the user were lost: the chat showed only a sentence like I've got the byte sizes for all 8 files in `files-A/`, ranging from 203 to 1496 bytes. Now I'll list `files-B/`. where the model had written a list of 8 file links with their sizes. The raw API dump shows that only this summary and the encrypted signatures come over the wire, so Zoo cannot recover the original. The model still sees its full note on later turns, so it doesn't notice the loss. Anthropic's prompting guide names the fix as the harness's job: > if the model may need to hand the user something verbatim partway > through a long turn, such as a code snippet, give it a simple tool > for sending the user a message and tell it to reserve the tool for > that content. Declare the tool in `tools` from the first request of > the session - New `send_user_message` tool with a `message` parameter. It shows the message as assistant text, streaming it while it arrives, and does not end or pause the turn like attempt_completion and ask_followup_question do. - New `ModelInfo.summarizesTextBetweenToolCalls`. Bedrock sets it for the progress-update models, and the tool policy offers the tool only when it is set, so other models' tool lists and prompts are unchanged. - When the tool is offered, the system prompt says that text outside tool calls reaches the user only as a short summary, and that verbatim content goes through send_user_message, attempt_completion or ask_followup_question. - Progress updates are now labelled "Zoo (progress update)" instead of "Zoo said", shown in the muted description colour, with a tooltip saying the provider sent the text as a progress update and that it may be shorter than what the model wrote. The label names the channel rather than calling the text a summary, because the generic progress_update chunk could carry full text for other providers. A new ClineMessage.progressUpdate flag carries this to the webview. Checked with a repro prompt (Opus 5.5 on Bedrock, raw API dump on, 2026-10-17) that asks for 4 Markdown link lists in chat text, each written before a tool call in the same turn, and asks not to repeat them in attempt_completion. Before this change, all 4 lists came back as one-sentence progress-update summaries, and 0 of the 16 file links reached the client, in each of 2 runs. With this change, all 4 lists went through send_user_message and all 16 links reached the client verbatim; the two lists written after the sizes were known had all 8 exact byte sizes each. No progress-update block appeared at all. The model broke the prompt's "one tool call per turn" to do this, and said why in a plain text block, which does reach the user verbatim: I'll send the list with `send_user_message`, because plain chat text only reaches you as a summary. That puts two tool calls in this turn. Only Zoo's Bedrock backend sets the flag so far; the Anthropic and Vertex providers don't request progress updates for these models yet. - https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5-5#user-facing-progress-updates - https://platform.claude.com/docs/en/build-with-claude/thinking#progress-updates See also Zoo-Code-Org#1820. Assisted-by: Claude Opus 5.5 with Zoo Code
1 parent 2f185d2 commit 0843a07

39 files changed

Lines changed: 424 additions & 21 deletions

‎packages/types/src/message.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ export const clineMessageSchema = z.object({
271271
*/
272272
contextTruncation: contextTruncationSchema.optional(),
273273
isProtected: z.boolean().optional(),
274+
/** Text the provider delivered as a progress update (inside a thinking block), not as a regular response. */
275+
progressUpdate: z.boolean().optional(),
274276
apiProtocol: z.union([z.literal("openai"), z.literal("anthropic")]).optional(),
275277
isAnswered: z.boolean().optional(),
276278
autoApprovalDecision: z.union([z.literal("approve"), z.literal("deny")]).optional(),

‎packages/types/src/model.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ export const modelInfoSchema = z.object({
164164
// These tools will be added if they belong to an allowed group in the current mode
165165
// Cannot force-add tools from groups the mode doesn't allow
166166
includedTools: z.array(z.string()).optional(),
167+
/**
168+
* The provider returns text the model writes between tool calls only as a short summary,
169+
* so verbatim content must go through `send_user_message`.
170+
* See https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5-5#user-facing-progress-updates
171+
*/
172+
summarizesTextBetweenToolCalls: z.boolean().optional(),
167173
/**
168174
* Service tiers with pricing information.
169175
* Each tier can have a name (for OpenAI service tiers) and pricing overrides.

‎packages/types/src/tool.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const toolNames = [
4242
"new_task",
4343
"codebase_search",
4444
"update_todo_list",
45+
"send_user_message",
4546
"run_slash_command",
4647
"skill",
4748
"generate_image",

‎src/api/providers/__tests__/bedrock.spec.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ describe("AwsBedrockHandler", () => {
181181
expect(modelInfo.info.contextWindow).toBeDefined()
182182
})
183183

184+
it.each([
185+
["anthropic.claude-opus-5-5", true],
186+
["anthropic.claude-3-5-sonnet-20241022-v2:0", false],
187+
])("flags whether %s returns text between tool calls only as a summary", (apiModelId, expected) => {
188+
const modelHandler = new AwsBedrockHandler({
189+
apiModelId,
190+
awsAccessKey: "test-access-key",
191+
awsSecretKey: "test-secret-key",
192+
awsRegion: "us-east-1",
193+
awsUseCrossRegionInference: true,
194+
})
195+
196+
expect(modelHandler.getModel().info.summarizesTextBetweenToolCalls === true).toBe(expected)
197+
})
198+
184199
it("should identify itself as Zoo Code in the AWS client app id", () => {
185200
expect(mockBedrockRuntimeClient).toHaveBeenCalledWith(
186201
expect.objectContaining({

‎src/api/providers/bedrock.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,11 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
15731573
}
15741574
}
15751575

1576+
if (this.writesProgressUpdates(modelConfig.id)) {
1577+
// Every thinking.display returns these models' text between tool calls only as a summary.
1578+
modelConfig.info = { ...modelConfig.info, summarizesTextBetweenToolCalls: true }
1579+
}
1580+
15761581
// Don't override maxTokens/contextWindow here; handled in getModelById (and includes user overrides)
15771582
return { ...modelConfig, ...params } as {
15781583
id: BedrockModelId | string

‎src/core/assistant-message/NativeToolCallParser.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,14 @@ export class NativeToolCallParser {
586586
}
587587
break
588588

589+
case "send_user_message":
590+
if (partialArgs.message !== undefined) {
591+
nativeArgs = {
592+
message: partialArgs.message,
593+
}
594+
}
595+
break
596+
589597
case "use_mcp_tool":
590598
if (partialArgs.server_name !== undefined || partialArgs.tool_name !== undefined) {
591599
nativeArgs = {
@@ -937,6 +945,14 @@ export class NativeToolCallParser {
937945
}
938946
break
939947

948+
case "send_user_message":
949+
if (args.message !== undefined) {
950+
nativeArgs = {
951+
message: args.message,
952+
} as NativeArgsFor<TName>
953+
}
954+
break
955+
940956
case "read_command_output":
941957
if (args.artifact_id !== undefined) {
942958
nativeArgs = {

‎src/core/assistant-message/__tests__/presentAssistantMessage-custom-tool.spec.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,20 @@ describe("presentAssistantMessage - Custom Tool Recording", () => {
339339
expect(mockTask.presentAssistantMessageLocked).toBe(false)
340340
})
341341

342+
it("marks a progress-update text block when showing it", async () => {
343+
mockTask.assistantMessageContent = [
344+
{ type: "text", content: "Checking the log.", partial: false, progressUpdate: true },
345+
{ type: "text", content: "Plain answer.", partial: false },
346+
]
347+
348+
await presentAssistantMessage(mockTask)
349+
350+
expect(mockTask.say.mock.calls).toEqual([
351+
["text", "Checking the log.", undefined, false, undefined, undefined, { progressUpdate: true }],
352+
["text", "Plain answer.", undefined, false],
353+
])
354+
})
355+
342356
it("stops internal continuation when the task aborts between blocks", async () => {
343357
mockTask.assistantMessageContent = [
344358
{ type: "text", content: "first", partial: false },

‎src/core/assistant-message/presentAssistantMessage.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { switchModeTool } from "../tools/SwitchModeTool"
3333
import { attemptCompletionTool, AttemptCompletionCallbacks } from "../tools/AttemptCompletionTool"
3434
import { newTaskTool } from "../tools/NewTaskTool"
3535
import { updateTodoListTool } from "../tools/UpdateTodoListTool"
36+
import { sendUserMessageTool } from "../tools/SendUserMessageTool"
3637
import { runSlashCommandTool } from "../tools/RunSlashCommandTool"
3738
import { skillTool } from "../tools/SkillTool"
3839
import { generateImageTool } from "../tools/GenerateImageTool"
@@ -452,7 +453,13 @@ async function presentAssistantMessageBlock(cline: Task): Promise<void> {
452453
content = content.replace(/\s?<\/thinking>/g, "")
453454
}
454455

455-
await cline.say("text", content, undefined, block.partial)
456+
if (block.progressUpdate) {
457+
await cline.say("text", content, undefined, block.partial, undefined, undefined, {
458+
progressUpdate: true,
459+
})
460+
} else {
461+
await cline.say("text", content, undefined, block.partial)
462+
}
456463
break
457464
}
458465
case "tool_use": {
@@ -530,6 +537,8 @@ async function presentAssistantMessageBlock(cline: Task): Promise<void> {
530537
return `[${block.name} for '${block.params.artifact_id}']`
531538
case "update_todo_list":
532539
return `[${block.name}]`
540+
case "send_user_message":
541+
return `[${block.name}]`
533542
case "new_task": {
534543
const mode = block.params.mode ?? defaultModeSlug
535544
const message = block.params.message ?? "(no message)"
@@ -904,6 +913,13 @@ async function presentAssistantMessageBlock(cline: Task): Promise<void> {
904913
pushToolResult,
905914
})
906915
break
916+
case "send_user_message":
917+
await sendUserMessageTool.handle(cline, block as ToolUse<"send_user_message">, {
918+
askApproval,
919+
handleError,
920+
pushToolResult,
921+
})
922+
break
907923
case "apply_diff":
908924
await checkpointSaveAndMark(cline)
909925
await applyDiffToolClass.handle(cline, block as ToolUse<"apply_diff">, {

‎src/core/prompts/__tests__/sections.spec.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,16 @@ describe("getRulesSection", () => {
364364
)
365365
})
366366

367+
it("tells the model to use send_user_message only when the tool is offered", () => {
368+
const summarizing = { contextWindow: 128_000, supportsPromptCache: true, summarizesTextBetweenToolCalls: true }
369+
const withTool = getRulesSection(cwd, settings, policyFor(["read"], { modelInfo: summarizing }))
370+
expect(withTool).toContain("reaches the user only as a short summary")
371+
expect(withTool).toContain("send_user_message")
372+
373+
const withoutTool = getRulesSection(cwd, settings, policyFor(["read"]))
374+
expect(withoutTool).not.toContain("send_user_message")
375+
})
376+
367377
it("omits the read_file rule when read_file is absent", () => {
368378
const result = getRulesSection(cwd, settings, policyFor(["command"]))
369379
expect(result).not.toContain("The user may provide a file's contents directly")

‎src/core/prompts/sections/rules.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export function getRulesSection(
8383
const chainNote = getCommandChainNote()
8484

8585
const hasExecuteCommand = policy.tools.has("execute_command")
86+
const hasSendUserMessage = policy.tools.has("send_user_message")
8687
const hasAskFollowupQuestion = policy.tools.has("ask_followup_question")
8788
const hasListFiles = policy.tools.has("list_files")
8889
const hasReadFile = policy.tools.has("read_file")
@@ -133,6 +134,12 @@ export function getRulesSection(
133134
: "Do not ask for more information than necessary. Use the tools provided to accomplish the user's request efficiently and effectively. When you've completed your task, present the result to the user. The user may provide feedback, which you can use to make improvements and try again.",
134135
)
135136

137+
if (hasSendUserMessage) {
138+
rules.push(
139+
"Text you write outside tool calls reaches the user only as a short summary. Put anything the user must see exactly (links, file paths, exact numbers, code, commands, lists of results) into a send_user_message call, or into the attempt_completion result or ask_followup_question question. send_user_message does not end or pause your turn.",
140+
)
141+
}
142+
136143
if (hasAskFollowupQuestion) {
137144
rules.push(
138145
`You are only allowed to ask the user questions using the ask_followup_question tool. Use this tool only when you need additional details to complete a task, and be sure to use a clear and concise question that will help you move forward with the task. When you ask a question, provide the user with 2-4 suggested answers based on your question so they don't need to do so much typing. The suggestions should be specific, actionable, and directly related to the completed task. They should be ordered by priority or logical sequence. However if you can use the available tools to avoid having to ask the user questions, you should do so.${

0 commit comments

Comments
 (0)