Skip to content

Subagent Premature Announce Bug - Model-Specific Tool Call Handling Issues #53810

Closed

Description

@FiredMosquito831

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:

  1. stopReason: "stop" instead of "toolUse"
  2. No pending tool calls detected
  3. Announce fires immediately
  4. 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:

  1. Same model, different endpoint - A model via OpenAI endpoint may behave differently than via Anthropic endpoint
  2. Different models, same provider - Different failure modes (truncated vs no output)
  3. 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

  1. Spawn a subagent with a complex research task
  2. Use kimi-k2.5 or MiniMax-M2.5 model via alibabatropic provider
  3. Task should require multiple tool calls
  4. Observe announce firing before task completion
  5. Check session history - tool calls in thinking blocks, stopReason: "stop"

Recommendations

Short-term

  1. Parse special tool call formats (<|tool_call_begin|>) in provider adapters
  2. Add detection for tool calls inside thinking blocks
  3. Normalize stopReason based on thinking content

Long-term

  1. Create model-specific adapters for models with non-standard behavior
  2. Implement universal tool call format normalization at provider level
  3. 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 queue
  • dist/gateway-cli-Cxz4pSoJ.js - StopReason handling
  • dist/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

Activity

  1. clawsweeper commented on Apr 27, 2026

    @clawsweeper
    Contributor

    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:

    Likely related people:

    • Ayaan Zaidi: Authored the released parser commit for Kimi tagged tool calls, which matches the marker family in this report. (role: introduced exact protocol handling; confidence: high; commits: d5ea5f27ac2b; files: extensions/kimi-coding/stream.ts, extensions/kimi-coding/stream.test.ts)
    • Peter Steinberger: Recent Kimi provider history includes the first-class Kimi K3 support and compatible replay-policy consolidation that maintain the surrounding stream boundary. (role: recent provider-area contributor; confidence: medium; commits: 3cec82e14579, 778edf0a8189; files: 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.

  2. clawsweeper commented on Apr 29, 2026

    @clawsweeper
    Contributor

    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 toolCall blocks, and changes stopReason to toolUse only after successful extraction.

    Acceptance criteria:

    • pnpm test extensions/qwen/stream.test.ts extensions/kimi-coding/stream.test.ts src/agents/openai-transport-stream.test.ts
    • pnpm check:changed (run in Testbox per repo policy before handoff)

    What I checked:

    • qwen_modelstudio_openai_transport: The bundled Qwen provider still builds ModelStudio/Qwen configs with api: "openai-completions", so affected output flows through the OpenAI-compatible completions transport. (extensions/qwen/provider-catalog.ts:4, acae48b790fa)
    • qwen_wrapper_scope: Qwen registers wrapQwenProviderStream, but the wrapper only sets enable_thinking and removes generic reasoning fields; it does not parse tagged tool-call sections or rewrite stopReason after extraction. (extensions/qwen/stream.ts:21, acae48b790fa)
    • generic_transport_structured_only: The OpenAI-compatible stream path appends reasoning deltas as text/thinking and creates toolCall blocks only from choice.delta.tool_calls; marker text inside reasoning fields is not parsed there. (src/agents/openai-transport-stream.ts:1383, acae48b790fa)
    • stop_reason_reset_without_structured_tool_call: After streaming, the transport resets stopReason from toolUse to stop when no structured toolCall block exists, matching the failure mode when provider marker text is left unparsed. (src/agents/openai-transport-stream.ts:1464, acae48b790fa)
    • kimi_parser_provider_local_text_only: The existing tagged marker parser is local to the Kimi plugin and only rewrites blocks where type is text; thinking/reasoning blocks and Qwen/ModelStudio streams are not covered. (extensions/kimi-coding/stream.ts:75, acae48b790fa)
    • affected_models_still_bundled_and_documented: The Qwen catalog and public provider docs still list MiniMax-M2.5 and kimi-k2.5, so the reported provider/model surface remains bundled and user-facing. (extensions/qwen/models.ts:74, acae48b790fa)

    Likely related people:

    • steipete: Local blame/log for the central Qwen stream wrapper, Kimi marker parser, OpenAI-compatible transport, and subagent announce paths resolves to Peter Steinberger in the available history, including the current main/release consolidation commits. (role: recent maintainer and current-file owner; confidence: medium; commits: a972c9ec4547, be8c24633aaa, acae48b790fa; files: extensions/qwen/stream.ts, extensions/qwen/index.ts, extensions/kimi-coding/stream.ts)
    • 100yenadmin: Provided related history shows recent work on subagent cleanup and OpenAI phase-aware visible text paths; this is adjacent routing context rather than direct Qwen marker-parser ownership. (role: adjacent subagent/runtime contributor; confidence: low; commits: 1152c26a7801; files: src/agents/subagent-registry.ts, src/agents/subagent-registry.archive.e2e.test.ts, src/agents/subagent-registry.persistence.test.ts)

    Remaining risk / open question:

    • The live failure is provider/model-specific and reportedly stochastic, so synthetic regression coverage should be paired with live Qwen/ModelStudio checks when credentials are available.
    • Promoting tagged tool calls from thinking/reasoning text needs conservative validation so ordinary model text that resembles markup is not executed as a tool call.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against acae48b790fa.

  3. added
    issue-rating: 🐚 platinum hermit
    clawsweeper:needs-live-repro
    P2
    impact:message-loss
    impact:session-state
    on May 19, 2026
  4. openclaw-barnacle commented on Jun 9, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  5. added
    stale
    on Jun 9, 2026
  6. added
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    on Jun 18, 2026
  7. removed
    stale
    on Jun 19, 2026
  8. added
    clawsweeper:needs-product-decision
    on Jun 19, 2026
  9. added
    clawsweeper:needs-security-review
    on Jun 27, 2026
  10. added
    impact:security
    on Jul 5, 2026
  11. 2 remaining items

  12. added
    issue-rating: 🦐 gold shrimp
    clawsweeper:needs-info
    issue-rating: 🦪 silver shellfish
    and removed
    clawsweeper:fix-shape-clear
    clawsweeper:needs-live-repro
    issue-rating: 🐚 platinum hermit
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    clawsweeper:needs-security-review
    clawsweeper:needs-info
    issue-rating: 🦐 gold shrimp
    on Jul 30, 2026
  13. locked as resolved and limited conversation to collaborators on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper-recovery-stuckimpact:message-lossimpact:session-stateissue-rating: 🦪 silver shellfish

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions