Repository navigation
Description
Subagent Premature Announce Bug - Model-Specific Tool Call Handling Issues
Summary
Subagents are being announced as "completed successfully" before they actually complete their work. This issue affects multiple models via different providers and endpoints, with behavior varying randomly based on the endpoint and model combination.
Affected Providers/Endpoints
| Provider | Endpoint | Models Affected | Issue Type |
|---|---|---|---|
| Alibaba Model Studio | OpenAI-compatible | kimi-k2.5, MiniMax-M2.5 | Tool call format mismatch, no output, truncated results |
| Alibaba Model Studio | Anthropic-compatible | Various | Random variations in behavior |
| Stability | - | Various | Random variations in behavior |
Root Cause
Certain models output tool calls in a non-standard format - inside thinking blocks using special markers:
<|tool_calls_section_begin|><|tool_call_begin|>function.exec:8<|tool_call_argument_begin|>{"command": "ls -la"}<|tool_call_end|>
OpenClaw's tool call detection expects structured toolCall blocks:
{
"type": "toolCall",
"id": "toolu_functions.exec:5",
"name": "exec",
"arguments": {"command": "ls -la"}
}This mismatch causes:
stopReason: "stop"instead of"toolUse"- No pending tool calls detected
- Announce fires immediately
- Tool calls never executed
Test Results
| Model | Result | Runtime | Tokens | Status |
|---|---|---|---|---|
| kimi-k2.5 | ❌ Truncated ("Let me fetch...") | ~1 min | ~800-1.5k | Bug Confirmed |
| MiniMax-M2.5 | ❌ No output at all | 4s | 0 | Different Bug |
| qwen3.5-plus | ✅ FULL RESULTS | 1m 47s | 116.8k | Works Correctly |
Key Finding: qwen3.5-plus works correctly, confirming the issue is model/provider-specific, not a system-wide bug.
Endpoint-Specific Behavior
The issues differ randomly based on endpoint and model:
- Same model, different endpoint - A model via OpenAI endpoint may behave differently than via Anthropic endpoint
- Different models, same provider - Different failure modes (truncated vs no output)
- Randomness factor - Same model + same endpoint can produce different failure modes
Evidence
Session History Example (kimi-k2.5)
{
"role": "assistant",
"content": [
{
"type": "thinking",
"thinking": "...<|tool_calls_section_begin|><|tool_call_begin|>function.exec:8..."
}
],
"stopReason": "stop",
"provider": "alibabatropic",
"model": "kimi-k2.5"
}Key observations:
stopReason: "stop"indicates no tool calls detected- Tool calls are present but as raw text inside thinking block
- Model was actively working but announce fired prematurely
Impact
- Subagents appear to complete successfully but have truncated/missing results
- No error indication - difficult to debug
- Lost work from research tasks
- Unreliable subagent orchestration for affected models
Steps to Reproduce
- Spawn a subagent with a complex research task
- Use
kimi-k2.5orMiniMax-M2.5model viaalibabatropicprovider - Task should require multiple tool calls
- Observe announce firing before task completion
- Check session history - tool calls in thinking blocks,
stopReason: "stop"
Recommendations
Short-term
- Parse special tool call formats (
<|tool_call_begin|>) in provider adapters - Add detection for tool calls inside thinking blocks
- Normalize
stopReasonbased on thinking content
Long-term
- Create model-specific adapters for models with non-standard behavior
- Implement universal tool call format normalization at provider level
- Add announce verification before firing
Immediate Workaround
Use qwen3.5-plus for subagent tasks until this is fixed.
Testing Matrix Needed
| Provider | Endpoint | Model | Test Status | Result |
|---|---|---|---|---|
| Alibaba Model Studio | OpenAI | kimi-k2.5 | ✅ Tested | ❌ Truncated |
| Alibaba Model Studio | OpenAI | MiniMax-M2.5 | ✅ Tested | ❌ No output |
| Alibaba Model Studio | OpenAI | qwen3.5-plus | ✅ Tested | ✅ Works |
| Alibaba Model Studio | Anthropic | kimi-k2.5 | ⏳ Not tested | ? |
| Alibaba Model Studio | Anthropic | MiniMax-M2.5 | ⏳ Not tested | ? |
| Alibaba Model Studio | Anthropic | qwen3.5-plus | ⏳ Not tested | ? |
| Stability | - | Various | ⏳ Not tested | ? |
Related Code Files
dist/pi-embedded-CzQCqSlH.js- Subagent announce queuedist/gateway-cli-Cxz4pSoJ.js- StopReason handlingdist/subagent-orphan-recovery-C-qEmldX.js- Subagent cleanup
Detailed Investigation
Full investigation report: workspace/docs/audits/subagent-announce-bug-2026-03-24/INVESTIGATION_REPORT.md
Environment:
- OpenClaw version: (from npm installation)
- Node.js: v22.22.0
- OS: Linux (WSL2)
- Affected providers: alibabatropic, modelstudio, stability
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Apr 27, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.The central false-success behavior is no longer current: OpenClaw has a dedicated Kimi parser for the exact tagged-tool-call protocol and a separate non-visible-turn guard that retries or visibly fails reasoning-only turns instead of silently finalizing them. The protocol parser shipped in v2026.4.5, so this issue no longer needs active backlog space.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the released provider-bound parser for Kimi’s tagged protocol and retain the generic non-visible-turn retry/error guard; do not execute arbitrary strings found in a reasoning block as tools.
Do we have a high-confidence way to reproduce the issue?
No current-main failure was established: current source parses the exact Kimi marker family on its provider path, while generic OpenAI- and Anthropic-compatible paths retry reasoning-only output and visibly report exhaustion. The supplied report lacks a complete redacted current-version trace for a remaining custom endpoint failure.
Is this the best way to solve the issue?
Yes. The released provider-specific parser is the safe owner-boundary repair for a known protocol, and the generic runtime safely turns unsupported non-visible output into retry/error rather than executing reasoning text as a tool call.
Security review:
Security review: No patch is under review.
AGENTS.md: found and applied where relevant.
What I checked:
extensions/kimi-coding/stream.ts:16, bac7d6bd5d8f)src/agents/embedded-agent-runner/run/incomplete-turn.ts:115, bac7d6bd5d8f)extensions/kimi-coding/stream.ts:16, d5ea5f27ac2b)extensions/kimi-coding/stream.ts:16, 3e72c0352dde)qa/maturity-scores.yaml, bac7d6bd5d8f)Likely related people:
extensions/kimi-coding/stream.ts,extensions/kimi-coding/stream.test.ts)extensions/kimi-coding/stream.ts,src/agents/embedded-agent-runner/run/incomplete-turn.ts)Codex review notes: model internal, reasoning high; reviewed against bac7d6bd5d8f; fix evidence: release v2026.4.5, commit d5ea5f27ac2b.
clawsweeper commentedon Apr 29, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.
Current main still lacks the reported provider/model-specific tagged tool-call normalization. Qwen/ModelStudio now has a stream wrapper, but it only patches thinking request fields; tagged tool calls embedded in reasoning/thinking text are still not promoted to structured tool calls, and the affected bundled models remain in the Qwen catalog and docs.
Required change / next step:
This is a narrow, source-local provider/runtime bug with clear likely files and regression tests; the main caution is keeping marker promotion conservative.
Review details
Best possible solution:
Add provider-owned Qwen/ModelStudio stream normalization, or a narrowly gated shared OpenAI-compatible helper, that extracts only validated standalone tagged tool-call sections from reasoning/thinking content, emits structured
toolCallblocks, and changesstopReasontotoolUseonly after successful extraction.Acceptance criteria:
What I checked:
api: "openai-completions", so affected output flows through the OpenAI-compatible completions transport. (extensions/qwen/provider-catalog.ts:4, acae48b790fa)wrapQwenProviderStream, but the wrapper only setsenable_thinkingand removes generic reasoning fields; it does not parse tagged tool-call sections or rewrite stopReason after extraction. (extensions/qwen/stream.ts:21, acae48b790fa)choice.delta.tool_calls; marker text inside reasoning fields is not parsed there. (src/agents/openai-transport-stream.ts:1383, acae48b790fa)stopReasonfromtoolUsetostopwhen no structured toolCall block exists, matching the failure mode when provider marker text is left unparsed. (src/agents/openai-transport-stream.ts:1464, acae48b790fa)typeistext; thinking/reasoning blocks and Qwen/ModelStudio streams are not covered. (extensions/kimi-coding/stream.ts:75, acae48b790fa)MiniMax-M2.5andkimi-k2.5, so the reported provider/model surface remains bundled and user-facing. (extensions/qwen/models.ts:74, acae48b790fa)Likely related people:
extensions/qwen/stream.ts,extensions/qwen/index.ts,extensions/kimi-coding/stream.ts)src/agents/subagent-registry.ts,src/agents/subagent-registry.archive.e2e.test.ts,src/agents/subagent-registry.persistence.test.ts)Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against acae48b790fa.
openclaw-barnacle commentedon Jun 9, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
2 remaining items