Repository navigation
Description
What happened
@M4n5ter A Bot Turn wrote a complete answer as ordinary text, did not call SendUser or sleep, and ended normally. Chat shows only the muted line from #6514, "The Bot did not reply this time". The answer is visible only under Execution.
The Bot's reasoning for that Turn ends with "I'll use SendUser.", and the next part is the answer as plain text. The system prompt is explicit ("the user sees only the messages you send with the SendUser tool… To respond to the user, call SendUser"), so the instruction is there and the model still did not follow it.
From the event log of that Turn (a fresh Root, the first Turn of the Bot):
- One
model_completedwith two parts:thinking(1385 reasoning tokens) andtext(the full answer, about 1900 output tokens in total). finish_reason: stop, no tool call in the step.- Then
invocation_ended. NoSendUser, nosleep.
So by #6514's table this is the "neither SendUser nor sleep (completed)" case, and the UI behaves as designed. This issue is about that outcome itself: the user asked a question, the model produced the answer, and it never reached them. They only find it by switching to Execution, where it sits among the reasoning and tool steps.
This is different from #6622, which was about text followed by sleep. You closed that one as deliberate silence, and that makes sense: the Bot chose to stop. Here it did not choose anything; the Turn just ran out.
How to reproduce
Not deterministic. It happens with K3.1 Pro on an Anthropic-compatible endpoint, mostly on long analytical questions. Ask the Bot an open-ended question in Chinese, for example a multi-year macro scenario question. In some Turns the answer is written as plain text and the Turn ends.
Environment
- rust-preview 1cba85e (desktop, macOS). The local build also carries an unrelated Chat prototype that does not touch the Bot engine or Bot UI.
- Model:
k3.1-prothrough a Kimi coding-plan connection (Anthropic Messages protocol).
Possible directions
- Remind once at the end of the Turn. When a Bot step finishes with final text and no tool call, and the Turn has sent nothing and not slept, the engine adds one short reminder ("Your text is not visible to the user. Send it with SendUser, or call sleep if nothing needs their attention.") and runs one more step. At most once per Turn, so a model that keeps ignoring it still ends. The answer then goes through
SendUserand the outbox as usual. The cost is one more model call that repeats the text. - Show the unsent text in Chat. Keep the muted line, and let it expand to show what the Bot wrote, marked as not sent. UI only and free, but the text is still not delivered: it never goes into the outbox.
- Leave it and treat it as a model-quality issue.
I lean towards 1, since it keeps "only SendUser reaches the user" intact and fixes the delivery, not just the display. Is this something you want to handle, or should we open a PR for the direction you prefer?
Activity
M4n5ter commentedon Nov 9, 2026
English
I think this should be addressed by completing the Bot execution contract discussed in #6464.Bot model requests should require a tool call where the provider supports it (tool_choice: required or the equivalent). The Bot can continue working with its other tools, use SendUser when it needs to communicate, and call sleep when it is done for now. Ordinary model text should not silently end the Bot turn.
We already added sleep in #6505, but the required tool choice was left out. Connecting it should address the text-only completion described here for providers that support it, without adding a separate reminder and extra model step as the primary path.
We still need an explicit fallback for providers or thinking modes that cannot enforce tool choice, and should verify the behavior against the K3.1 Pro endpoint used in this report.
中文
我认为这里应该补全之前在 #6464 讨论过的 Bot 执行契约。对于支持强制工具调用的 provider,Bot 模型请求应使用 tool_choice: required 或对应配置。Bot 可以继续调用其他工具完成工作,需要告知用户时调用 SendUser,暂时完成时调用 sleep。普通模型文本不应该让 Bot 这一轮静默结束。
#6505 已经加入了 sleep,但强制工具调用当时没有纳入。把它接上后,应该能解决支持该能力的 provider 在这里出现的纯文本结束问题,而不必首先通过额外提醒和增加一次模型调用来处理。
对于无法强制工具调用的 provider 或思考模式,仍需要明确的兜底策略;也需要针对这次报告使用的 K3.1 Pro 端点验证实际行为。
YongGoose commentedon Nov 11, 2026
Hi @UncertaintyDeterminesYou4ndMe, thank you for the detailed report.
If you haven't started on this yet, would you mind if I took it? I'd follow the direction suggested above: require a tool call for Bot requests where the provider supports it, with an explicit fallback for providers or thinking modes that can't enforce it.
If you'd rather open the PR yourself, that's completely fine. Just let me know.
jackeyfaker77 commentedon Nov 18, 2026
English
Picking this up (
takeabove, as it is still unassigned) — happy to coordinate if @YongGoose already has work in progress.Following @M4n5ter's direction to complete the #6464 / #6505 Bot execution contract on
rust-preview:Primary path — require a tool call on Bot turns (
ToolChoiceMode::Required):RequiredtoToolChoiceMode(maka-agent-facts/maka-model) and set it on Bot main-turn requests (leaving non-Bot sessions onAutoand summary repair onNone).Requiredacross the protocol adapters: Anthropic Messages (WireChoice::Anywhenpolicy.forced_choiceholds), Chat Completions ("required"), and OpenAI Responses ("required").Explicit fallback for thinking modes / providers that cannot enforce
tool_choice:PreparedTools::build(anthropic/request.rs) already downgradesRequired→Auto(ForcedToolChoiceIgnored) when budgeted thinking orreject_forcedadaptive thinking is active — which matches the reportedk3.1-pro(Anthropic protocol + thinking) trace. Other compatible relays may also reject or ignore forced tool choice.Auto(or a provider rejects forcedtool_choice/ still finishes a step withstop, plain text, and zero tool calls while the Bot Turn has neither calledSendUsernorsleep), run at most one bounded follow-up step reminding the Bot to deliver viaSendUseror finish withsleep(and if an endpoint rejects forcedtool_choiceat HTTP level, retry once withAutobefore applying that guard). If the follow-up still produces noSendUser/sleep, let the Turn settle normally without looping.Verification:
Requiredwire encoding across protocols, thinking-mode downgrade + single-step fallback recovery, non-looping termination when the fallback is still ignored, andsleep/ steering interaction.k3.1-proonkimi-coding-plan(Anthropic Messages, with and without thinking), or explicit reporting if a specific endpoint combination behaves differently.中文
看当前还没有分配,我先
take认领推进(如果 @YongGoose 已有在途改动欢迎随时同步)。按 @M4n5ter 指出的方向,在
rust-preview上补全 #6464 / #6505 的 Bot 执行契约:主路径 —— Bot 请求默认强制工具调用(
ToolChoiceMode::Required):ToolChoiceMode(maka-agent-facts/maka-model)补充Required,仅对 Bot 主循环请求启用(普通会话保持Auto,summary repair 保持None)。policy.forced_choice允许时发WireChoice::Any)、Chat Completions("required")与 OpenAI Responses("required")。不支持强制工具调用的思考模式 / Provider 显式兜底:
reject_forcedadaptive thinking 时,PreparedTools::build已会将Required降级为Auto(ForcedToolChoiceIgnored)——这正对应本单k3.1-pro(Anthropic 协议 + 1385 推理 token)的场景;部分兼容网关也可能拒绝或忽略强制tool_choice。Auto(若网关对强制tool_choice直接报参数错误则单次降级Auto重试),或模型仍在零工具调用、未调SendUser且未sleep的情况下以纯文本stop结束时,在引擎侧执行每轮最多一次的受限追问步,提示通过SendUser发送或调用sleep结束;若追问步仍未调用,则正常收敛结束,绝不死循环。验证:
Required编码、思考模式降级 + 单次兜底恢复、二次忽略不死循环以及与sleep/steering 交互的行为测试。kimi-coding-plank3.1-pro(含开关思考模式)做实测验证并附上结果。jackeyfaker77 commentedon Nov 18, 2026
untake
YongGoose commentedon Nov 18, 2026
If @UncertaintyDeterminesYou4ndMe isn't planning to proceed, please feel free to go ahead!
I'm happy to step aside and let you take this one. Just let me know if you'd like me to review it!
fix(agent): require Bot tool calls with bounded plain-text fallback
fix(agent): require Bot tool calls with bounded plain-text fallback
fix(agent): require Bot tool calls with bounded plain-text fallback
fix(agent): require Bot tool calls with bounded plain-text fallback
Prathmesh010190 commentedon Nov 22, 2026
Complete solution approach, grounded in the codebase
Hi @UncertaintyDeterminesYou4ndMe and @M4n5ter, I've read through the full execution path in the local source and want to lay out a precise, self-contained fix. Happy to open a PR for this.
Root cause (confirmed from source)
Three files tell the whole story:
plugins/agent/facts/src/model/request.rs(line 100)ToolChoiceModecurrently has only two variants:Auto(the default) andNone. There is noRequiredvariant, so there is no way to tell the wire layer to force a tool call.plugins/agent/native/src/owner/driver_model.rs(lines 801 and 1765)Both
PromptSettingsconstruction sites for Bot main turns hard-codetool_choice: ToolChoiceMode::Auto.Autolets the model decide, so a thinking-mode model (e.g. k3.1-pro via Anthropic Messages) can finish reasoning, write the answer as plain text, and returnfinish_reason: stopwith zero tool calls.SendUseris never called, so the answer is invisible to the user.plugins/agent/model/src/adapters/request.rs(lines 118–121 and 201–203)The Anthropic and Chat Completions adapter match arms only cover
AutoandNone. There is no code path that emits{"type":"any"}or"required"today.The fix: 4 coordinated changes
1. Add
RequiredtoToolChoiceModeFile:
plugins/agent/facts/src/model/request.rsBackward-compatible: the serde tag is
"required"(snake_case). Old frozen inputs serialized as"auto"continue to deserialize correctly.2. Set
Requiredat bothPromptSettingssitesFile:
plugins/agent/native/src/owner/driver_model.rsThe
CompositionSurfacestruct (fromplugins/agent/facts/src/composition.rs) already holdstools: Vec<Arc<ToolDefinition>>. Check whether bothSendUserandsleepare present in that list; if so, and it is a main (non-summary) turn, useRequired.3. Wire
Requiredthrough all three protocol adaptersFile:
plugins/agent/model/src/adapters/request.rsAnthropic Messages (lines 118–121):
Chat Completions (lines 201–203):
OpenAI Responses (
adapters/responses/request.rs, lines 362–363):Add matching
Requiredvariants to the wire types inmaka-provider-protocol.4. Thinking-mode downgrade + single-step bounded fallback
This is the critical path for the reported k3.1-pro case (Anthropic Messages + 1385 reasoning tokens). Anthropic rejects
{"type":"any"}whenbudgetedorreject_forcedthinking is active.Static downgrade in
PreparedTools::build(Anthropic request path):Dynamic retry for providers that reject at HTTP level:
Engine-level fallback (the safety net for both downgrade paths):
When a main-turn model step closes with
finish_reason: Stop, zero tool calls, noSendUseroutput recorded, nosleepcalled, and no fallback has fired for this Turn yet:Fact::PlaintextFallbackFired { attempt: ModelAttemptId }(new variant added to theFactenum indurable.rs; taggedplaintext_fallback_fired).Summary of what changes where
facts/src/model/request.rsRequiredvariant toToolChoiceModefacts/src/durable.rsPlaintextFallbackFiredtoFactenumnative/src/owner/driver_model.rs(lines 801, 1765)Requiredon Bot main turnsmodel/src/adapters/request.rs(lines 118–121, 201–203)Requiredin Anthropic + Chat Completionsmodel/src/adapters/responses/request.rs(lines 362–363)Requiredin Responsesengine/src/driver.rsPlaintextFallbackFireddetection + single bounded follow-upRequired tests (to prevent regression)
ToolChoiceMode::Requiredserializes as"required"and round-tripsRequired→{"type":"any"}Required→"required"Required→"required"Required; ordinary session →Auto; summary repair →NoneAutobefore sendtool_choice→ retry withAuto, endpoint cachedSendUser→ fallback fires once →SendUsercalled → reaches outboxPlaintextFallbackFiredcorrectly classified asis_late(), notis_admission()Happy to open a PR for this. Let me know which direction works best for the team.