Skip to content

fix(agents): recover reasoning-only and bare tool-call settled-turn answers - #174376

Merged
steipete merged 3 commits into
openclaw:mainfrom
arthur-drozdov:fix/settled-turn-answer-recovery
Oct 17, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
arthur-drozdov:fix/settled-turn-answer-recovery

Conversation

@arthur-drozdov

@arthur-drozdov arthur-drozdov commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a missing final answer after settled tools when the model emits only reasoning or a bare unfinished <tool_call> marker, including output-limit endings and projected transcripts.

User Impact

OpenClaw can compose an answer from settled tool results without repeating completed tools. Meaningful partial answers, intentional silence, delivered replies, and outstanding-work safety guards retain their existing behavior. The configured model and requested thinking preference remain intact.

Why This Change Was Made

The existing settled-turn finalizer now tests for absence of visible text and accepts both stop and length, using the canonical current/completed assistant resolver. The shared visible-text sanitizer checks existing Markdown code regions before removing a standalone unfinished tool-call opener, preserving quoted, fenced, indented, and explanatory examples. The terminal-reply owner remains the single classifier; this does not add another recovery pass or provider-specific thinking override.

Merged main into Arthur Drozdov's original branch, retaining his commits and the general repair. Thanks @arthur-drozdov. The earlier local-Qwen override and redundant classification sanitizer are removed; the existing provider owner keeps responsibility for thinking support.

Production changes: +11/-6 (net +5); tests: +134/-0; documentation: +1/-1, relative to merged main 4453e5570f6a2cea77af7e111869c199cd0b42fc. The small production growth expresses the expanded stop condition and canonical bare-marker rule after removing a redundant settlement check. No model-facing prompt changes; token delta zero.

Evidence

  • The final visible-text and recovery suites pass 100/100 tests (158.45s wall), including four-space/tab-indented code and delivery preservation. The earlier settlement evidence and finalization/harness suites also pass. The narrowed regression on unchanged main failed the three intended recovery cases and passed all 11 controls (316.80s); a direct owner probe reproduced both indentation deletions before the Markdown correction.
  • Core and fresh agents-other types, scoped lint, formatting, and git diff --check pass. An earlier incremental type-cache diagnostic disappeared on fresh exact-base and candidate graphs; no source workaround was added.
  • Full pnpm build passes on the final correction (491.33s), including all 155 SDK export checks and UI startup budgets. No prompt text changed.
  • Line-cap, assertion-safety, timeout-race, mock-export, config-doc and plugin-inventory checks pass. Max-lines reports three unchanged UI suppressions; the exact merged base reproduces the same failures (113.09s). This is inherited.
  • Independent Codex review: scoped-clean through P2, no actionable findings.
  • Six deterministic streamed-provider cases through the real CLI pass: reasoning-only stop, reasoning-only length, and bare-marker length, each with both qwen and qwen-chat-template. Every case returns the expected answer, records exactly one physical exec effect, and makes three requests with zero tools in the finalizer. All requests preserve the correct top-level or nested enable_thinking: true. Case wall times: 33.9–46.6s; agent times: 4.27–5.86s.
  • Native Ollama qwen3:4b and qwen3:8b both return EFFECT_OK after one successful exec effect and two /api/chat requests with think: "medium". Wall/agent times: 108.195/70.205s and 56.179/24.291s respectively. Both use num_ctx: 32768 and num_predict: 4096.

The six-case matrix and native controls were recorded on 085de052e19. After the Markdown guard correction, both bare-marker formats were rerun on 72674527bbc: both pass with one effect and a zero-tool finalizer (wall/agent 29.555/5.278s and 40.560/3.929s). The 100-test final run also proves indented examples survive delivery.

CLI command surface: pnpm openclaw --profile reasoning-only-recovery agent --local --agent main --thinking medium --json, with a fresh session, task-specific state/config/workspace, and a loopback request recorder. No operator Gateway, state, or service is used.

Baseline distinction: ordinary full-transcript reasoning-only stop and length already recover on main. The new reasoning regression covers projected snapshots omitting the tool batch, including a completed response retained after the current snapshot slot is absent. The actual CLI before/after defect is the bare-marker output-limit reply: baseline makes two provider requests, records one real tool effect, skips the finalizer, and returns the marker plus a truncation notice.

All CLI proof uses the real isolated pnpm openclaw --profile reasoning-only-recovery agent --local entry point on macOS. Deterministic provider requests cover both declared Qwen thinking formats. Native Ollama smoke uses qwen3:4b and qwen3:8b; these are control runs, not claims that a natural model deterministically reproduces the defect. No cross-platform proof or performance comparison is claimed.

Captured bare-marker CLI output and request/effect trace

Extracts below come from actual isolated local-agent CLI output, recorded provider requests, and a file that each completed tool call appends to. The deterministic local provider emits one tool call, then a bare <tool_call> with a length stop. Paths, addresses, credentials, and run/session identifiers are omitted.

Before repair

{
  "thinkingFormat": "qwen",
  "cliOutput": {"payloads": [{"text": "<tool_call>"}, {"text": "⚠️ Reply truncated at the model's output token limit. The text above is partial — ask to continue it."}], "terminalReply": {"disposition": "visible", "text": "<tool_call>"}, "toolSummary": {"calls": 1, "tools": ["exec"], "failures": 0}},
  "physicalToolEffects": 1,
  "providerRequests": 2,
  "toolsPerRequest": [4, 4],
  "finalizerRequests": 0,
  "thinkingPerRequest": [{"enable_thinking": true}, {"enable_thinking": true}]
}

After repair: qwen

{
  "thinkingFormat": "qwen",
  "cliOutput": {"payloads": [{"text": "Recovered bare-marker; one recorded effect."}], "terminalReply": {"disposition": "visible", "text": "Recovered bare-marker; one recorded effect."}, "toolSummary": {"calls": 1, "tools": ["exec"], "failures": 0}},
  "physicalToolEffects": 1,
  "providerRequests": 3,
  "toolsPerRequest": [4, 4, 0],
  "finalizerRequests": 1,
  "thinkingPerRequest": [{"enable_thinking": true}, {"enable_thinking": true}, {"enable_thinking": true}]
}

After repair: qwen-chat-template

{
  "thinkingFormat": "qwen-chat-template",
  "cliOutput": {"payloads": [{"text": "Recovered bare-marker; one recorded effect."}], "terminalReply": {"disposition": "visible", "text": "Recovered bare-marker; one recorded effect."}, "toolSummary": {"calls": 1, "tools": ["exec"], "failures": 0}},
  "physicalToolEffects": 1,
  "providerRequests": 3,
  "toolsPerRequest": [4, 4, 0],
  "finalizerRequests": 1,
  "thinkingPerRequest": [{"chat_template_kwargs": {"enable_thinking": true}}, {"chat_template_kwargs": {"enable_thinking": true}}, {"chat_template_kwargs": {"enable_thinking": true}}]
}

Both repaired runs returned the answer through the existing finalizer with zero tools. Each completed exactly one tool effect and retained the configured thinking format with thinking enabled. These captures use a deterministic provider; the separately reported native Qwen smoke runs exercised real models.

…nswers

A settled tool turn that ends with a signed reasoning-only stop, an output
limit that leaves no answer after transport markup removal, or a bare
unterminated <tool_call> transport marker was classified as a delivered
answer, silently losing the reply. Route non-visible stops after settled
tools to the existing tool-disabled finalizer (never another tool-enabled
attempt), treat a lone bare tool-call marker as non-visible text, and
reserve the local Qwen finalizer pass for text by disabling thinking there.

Ported from a digest-fenced live hotfix qualified on 2026.10.2 (reasoning-only
and bare tool_call terminals diagnosed 2026-10-15); delivery-state guards
omitted because main now routes delivered/pending replies to the finalizer
by design.
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR routes non-visible settled-tool endings through existing tool-free finalization and hides bare unfinished tool-call markers while preserving Markdown examples.

Example: A Qwen response ends at its output limit with only <tool_call> after one successful exec call.

  • Before: The CLI returns <tool_call> and a truncation notice after two provider requests.
  • After: A third, tool-free request returns “Recovered bare-marker; one recorded effect.” without repeating exec.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused shared-owner repair with captured CLI before/after evidence, resolved earlier findings, and no remaining actionable defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Captured isolated macOS CLI runs exercise bare-marker output-limit recovery through the real local-agent entry point at the reviewed head, returning the final answer with one physical exec effect and zero tools in finalization for both Qwen wire formats; projected-response cases have focused regression coverage, and native Ollama runs are correctly identified as controls.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users can receive unfinished tool markup or no composed answer after their tools have already completed successfully.
Reason: The change restores documented missing-answer recovery with a small shared-owner repair and no new setting, provider override, or recovery subsystem.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete missing-answer path that remains on current main; both earlier findings are resolved, and no actionable correctness defect remains.

Priority: P2
Reviewed head: 72674527bbc930199f70499b6201795ff7b09e6c

Before merge

None.

Findings

None.

Agent review details

How this fits together

The embedded runner classifies assistant output after tool settlement, checks delivery and outstanding work, and passes eligible missing answers to the existing tool-free finalizer before preparing terminal reply payloads.

flowchart TD
  A[Provider response and settled tools] --> B[Canonical visible text sanitizer]
  B --> C[Current assistant classification]
  C --> D[Settlement and delivery guards]
  D --> E[Existing tool free finalizer]
  E --> F[Terminal reply preparation]
  F --> G[CLI or channel delivery]
Loading

Technical review

Best possible solution:

Land the focused repair through the existing finalization owner once the normal exact-head gates pass.

Do we have a high-confidence way to reproduce the issue?

Current-main source exposes the bare-marker length-stop failure and projected-response recovery gap; the supplied CLI before/after captures independently demonstrate the bare-marker case, without this review executing target code.

Is this the best way to solve the issue?

The repair fits the existing shared sanitizer and tool-free finalization owners, preserves model selection and thinking preferences, and retains the guards against replay, outstanding work, duplicate delivery, and intentional silence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d7509bb8c66f.

Provenance checked

  • Settled-tool continuation eligibility keeps the original intent (c55d9b6: Preserve intentional terminal-tool completion while allowing safe finalization of genuinely missing answers; later silent-continuation work preserves current-answer selection.)
  • Tool XML sanitizer and Markdown protection keeps the original intent (b656d96: Avoid repeated Markdown parsing after quoted XML while preserving code examples and hiding actual transport scaffolding.)
  • Documented terminal reply behavior keeps the original intent (bd5f760: Separate deliberate silence from missing output and recover owed answers without fabricated assistant replies.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c55d9b6 adds src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts:326 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c55d9b6d207b; files: src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts)

PR surface

Source +5, Tests +134, Docs 0. Total +139 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 11 6 +5
Tests 2 134 0 +134
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 146 7 +139

Review metrics

Metric Value Why it matters
Production versus test LOC Production +11/-6; tests +134/-0 The small production increase extends an existing recovery condition and sanitizer rule; tests cover projected responses, stop reasons, safety controls, and literal Markdown preservation.

Labels

Label changes:

  • add P2: A bounded provider-output failure can lose the composed answer after successful tools, but the evidence does not establish a widespread urgent regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster. Replaced prior rating: 🧂 unranked krab.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove P1: Current review triage priority is P2, so this older priority label is no longer current.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove merge-risk: 🚨 auth-provider: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A bounded provider-output failure can lose the composed answer after successful tools, but the evidence does not establish a widespread urgent regression.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster. Replaced prior rating: 🧂 unranked krab.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-16T15:53:16.894Z sha 5388312 :: needs real behavior proof before merge. :: [P2] Preserve the model's configured Qwen wire format
  • reviewed 2026-10-16T23:42:00.982Z sha 085de05 :: needs real behavior proof before merge. :: [P2] Preserve indented code before removing the bare marker

Reviewed October 16, 2026, 8:06 PM ET / October 17, 2026, 00:06 UTC (Revision 3).

Use the current response's visible text to admit settled-tool finalization
for stop and length endings, including projected transcripts. Strip a lone
unfinished tool-call marker in the canonical visible-text sanitizer.

Keep the configured model and thinking preference in the existing tool-free
finalizer. Preserve meaningful partial replies and settled-work safety guards.
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 16, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@steipete steipete self-assigned this Oct 17, 2026
@steipete
steipete merged commit a9033d5 into openclaw:main Oct 17, 2026
130 of 133 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…nswers (openclaw#174376)

## What Problem This Solves

Fixes a missing final answer after settled tools when the model emits only reasoning or a bare unfinished `<tool_call>` marker, including output-limit endings and projected transcripts.

## User Impact

OpenClaw can compose an answer from settled tool results without repeating completed tools. Meaningful partial answers, intentional silence, delivered replies, and outstanding-work safety guards retain their existing behavior. The configured model and requested thinking preference remain intact.

## Why This Change Was Made

The existing settled-turn finalizer now tests for absence of visible text and accepts both `stop` and `length`, using the canonical current/completed assistant resolver. The shared visible-text sanitizer checks existing Markdown code regions before removing a standalone unfinished tool-call opener, preserving quoted, fenced, indented, and explanatory examples. The terminal-reply owner remains the single classifier; this does not add another recovery pass or provider-specific thinking override.

Merged main into Arthur Drozdov's original branch, retaining his commits and the general repair. Thanks @arthur-drozdov. The earlier local-Qwen override and redundant classification sanitizer are removed; the existing provider owner keeps responsibility for thinking support.

Production changes: +11/-6 (net +5); tests: +134/-0; documentation: +1/-1, relative to merged main `421b1d62236cf2912f71fb53ca12546bab5c477b`. The small production growth expresses the expanded stop condition and canonical bare-marker rule after removing a redundant settlement check. No model-facing prompt changes; token delta zero.

## Evidence

- The final visible-text and recovery suites pass 100/100 tests (158.45s wall), including four-space/tab-indented code and delivery preservation. The earlier settlement evidence and finalization/harness suites also pass. The narrowed regression on unchanged main failed the three intended recovery cases and passed all 11 controls (316.80s); a direct owner probe reproduced both indentation deletions before the Markdown correction.
- Core and fresh agents-other types, scoped lint, formatting, and `git diff --check` pass. An earlier incremental type-cache diagnostic disappeared on fresh exact-base and candidate graphs; no source workaround was added.
- Full `pnpm build` passes on the final correction (491.33s), including all 155 SDK export checks and UI startup budgets. No prompt text changed.
- Line-cap, assertion-safety, timeout-race, mock-export, config-doc and plugin-inventory checks pass. Max-lines reports three unchanged UI suppressions; the exact merged base reproduces the same failures (113.09s). This is inherited.
- Independent Codex review: scoped-clean through P2, no actionable findings.
- Six deterministic streamed-provider cases through the real CLI pass: reasoning-only `stop`, reasoning-only `length`, and bare-marker `length`, each with both `qwen` and `qwen-chat-template`. Every case returns the expected answer, records exactly one physical `exec` effect, and makes three requests with zero tools in the finalizer. All requests preserve the correct top-level or nested `enable_thinking: true`. Case wall times: 33.9–46.6s; agent times: 4.27–5.86s.
- Native Ollama `qwen3:4b` and `qwen3:8b` both return `EFFECT_OK` after one successful `exec` effect and two `/api/chat` requests with `think: "medium"`. Wall/agent times: 108.195/70.205s and 56.179/24.291s respectively. Both use `num_ctx: 32768` and `num_predict: 4096`.

The six-case matrix and native controls were recorded on `085de052e19`. After the Markdown guard correction, both bare-marker formats were rerun on `72674527bbc`: both pass with one effect and a zero-tool finalizer (wall/agent 29.555/5.278s and 40.560/3.929s). The 100-test final run also proves indented examples survive delivery.

CLI command surface: `pnpm openclaw --profile reasoning-only-recovery agent --local --agent main --thinking medium --json`, with a fresh session, task-specific state/config/workspace, and a loopback request recorder. No operator Gateway, state, or service is used.

Baseline distinction: ordinary full-transcript reasoning-only `stop` and `length` already recover on main. The new reasoning regression covers projected snapshots omitting the tool batch, including a completed response retained after the current snapshot slot is absent. The actual CLI before/after defect is the bare-marker output-limit reply: baseline makes two provider requests, records one real tool effect, skips the finalizer, and returns the marker plus a truncation notice.

All CLI proof uses the real isolated `pnpm openclaw --profile reasoning-only-recovery agent --local` entry point on macOS. Deterministic provider requests cover both declared Qwen thinking formats. Native Ollama smoke uses qwen3:4b and qwen3:8b; these are control runs, not claims that a natural model deterministically reproduces the defect. No cross-platform proof or performance comparison is claimed.

<details>
<summary>Captured bare-marker CLI output and request/effect trace</summary>

Extracts below come from actual isolated local-agent CLI output, recorded provider requests, and a file that each completed tool call appends to. The deterministic local provider emits one tool call, then a bare `<tool_call>` with a length stop. Paths, addresses, credentials, and run/session identifiers are omitted.

### Before repair

```json
{
  "thinkingFormat": "qwen",
  "cliOutput": {"payloads": [{"text": "<tool_call>"}, {"text": "⚠️ Reply truncated at the model's output token limit. The text above is partial — ask to continue it."}], "terminalReply": {"disposition": "visible", "text": "<tool_call>"}, "toolSummary": {"calls": 1, "tools": ["exec"], "failures": 0}},
  "physicalToolEffects": 1,
  "providerRequests": 2,
  "toolsPerRequest": [4, 4],
  "finalizerRequests": 0,
  "thinkingPerRequest": [{"enable_thinking": true}, {"enable_thinking": true}]
}
```

### After repair: qwen

```json
{
  "thinkingFormat": "qwen",
  "cliOutput": {"payloads": [{"text": "Recovered bare-marker; one recorded effect."}], "terminalReply": {"disposition": "visible", "text": "Recovered bare-marker; one recorded effect."}, "toolSummary": {"calls": 1, "tools": ["exec"], "failures": 0}},
  "physicalToolEffects": 1,
  "providerRequests": 3,
  "toolsPerRequest": [4, 4, 0],
  "finalizerRequests": 1,
  "thinkingPerRequest": [{"enable_thinking": true}, {"enable_thinking": true}, {"enable_thinking": true}]
}
```

### After repair: qwen-chat-template

```json
{
  "thinkingFormat": "qwen-chat-template",
  "cliOutput": {"payloads": [{"text": "Recovered bare-marker; one recorded effect."}], "terminalReply": {"disposition": "visible", "text": "Recovered bare-marker; one recorded effect."}, "toolSummary": {"calls": 1, "tools": ["exec"], "failures": 0}},
  "physicalToolEffects": 1,
  "providerRequests": 3,
  "toolsPerRequest": [4, 4, 0],
  "finalizerRequests": 1,
  "thinkingPerRequest": [{"chat_template_kwargs": {"enable_thinking": true}}, {"chat_template_kwargs": {"enable_thinking": true}}, {"chat_template_kwargs": {"enable_thinking": true}}]
}
```

Both repaired runs returned the answer through the existing finalizer with zero tools. Each completed exactly one tool effect and retained the configured thinking format with thinking enabled. These captures use a deterministic provider; the separately reported native Qwen smoke runs exercised real models.

</details>


Co-authored-by: Arthur Drozdov <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…aming (#175472)

fix(text): stop re-parsing streamed Markdown for ordinary HTML/JSX markup

While a long reply streamed, the tool-call XML filter parsed the whole growing Markdown text for every ordinary less-than sign, so long HTML/JSX answers burned a lot of Gateway CPU. The Markdown ownership check now runs only for text that could start a tool-call tag.

Thanks @JasonBuildAI.

Release adaptation: the stable filter predates main's streaming-prefix hold
(#174376), isToolCallTagPrefix, isInsideSettledBlockCode, and the protection
fast-path scanner. Ported the fix logic onto the stable loop instead: the
Markdown ownership parse (findCodeRegions) now runs only for a complete
tool-call tag candidate, and an unfinished trailing tag name (e.g. "<p") is
rescanned on the next append without any parse, which covers the
partial-boundary stall fixed on main by edbe9a2 (#180765). Both
outcomes previously returned false, so the projection output is unchanged.
Ported the #175472 and #180765 work-count and chunk-boundary parity tests
(without main's streaming flag). 37e5e6c (#181397, stall after a real
tool-call XML activates the filter) is a separate bug that depends on
main-only ownership reuse (#175328) and diverged stream handlers; not
included.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 2ad3797)
Includes fix logic from commit edbe9a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. docs Improvements or additions to documentation merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants