Skip to content

fix: preserve LM Studio Responses tool arguments#90593

Merged
steipete merged 1 commit into
openclaw:mainfrom
849261680:fix/90585-lmstudio-responses-tool-args
Jun 7, 2026
Merged

fix: preserve LM Studio Responses tool arguments#90593
steipete merged 1 commit into
openclaw:mainfrom
849261680:fix/90585-lmstudio-responses-tool-args

Conversation

@849261680

@849261680 849261680 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve streamed OpenAI Responses tool-call arguments when the final response.function_call_arguments.done event omits arguments or sends an empty string.
  • Add shared parser regression coverage for both LM Studio-style done event shapes.

Fixes #90585.

Verification

  • node scripts/run-vitest.mjs src/llm/providers/openai-responses-shared.test.ts
  • node scripts/run-vitest.mjs extensions/lmstudio/src/stream.test.ts
  • ./node_modules/.bin/oxfmt --check --threads=1 src/llm/providers/openai-responses-shared.ts src/llm/providers/openai-responses-shared.test.ts
  • git diff --check
  • .agents/skills/autoreview/scripts/autoreview --mode local -> clean, no accepted/actionable findings

Real behavior proof

Behavior addressed: LM Studio/OpenAI-compatible Responses streams can emit function-call argument deltas, then a response.function_call_arguments.done event whose arguments field is missing or empty. The parser now keeps the accumulated delta JSON instead of replacing it with an empty/missing final payload.

Real environment tested: Local OpenAI-compatible HTTP/SSE fixture exercised through streamSimpleOpenAIResponses, using a real POST to /responses and streamed SSE events matching the LM Studio failure shape. Local LM Studio itself was checked at http://127.0.0.1:1234/v1/models, but no LM Studio server was running on this machine.

Exact steps or command run after this patch: Ran a one-shot node --import tsx --input-type=module script that started an HTTP server, returned Responses SSE events with response.function_call_arguments.delta followed by response.function_call_arguments.done without arguments, and consumed it through streamSimpleOpenAIResponses.

Evidence after fix: Copied terminal output from the local HTTP/SSE fixture run:

{
  "ok": true,
  "eventTypes": [
    "start",
    "toolcall_start",
    "toolcall_delta",
    "toolcall_end",
    "done"
  ],
  "stopReason": "toolUse",
  "toolCall": {
    "type": "toolCall",
    "id": "call_read|fc_read",
    "name": "read",
    "arguments": {
      "path": "docs/gateway/local-models.md"
    }
  },
  "requestPath": "/responses",
  "requestStream": true
}

Observed result after fix: The streamed read tool call retained its path argument and the provider stream ended with stopReason: "toolUse".

What was not tested: A live LM Studio model run was not possible because 127.0.0.1:1234 was not reachable in this environment.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 5, 2026
@clawsweeper

clawsweeper Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 7, 2026, 3:12 AM ET / 07:12 UTC.

Summary
The PR preserves streamed OpenAI Responses tool-call arguments when the final function-call-arguments done event omits or sends empty arguments, and adds regression coverage for both shapes.

PR surface: Source +7, Tests +106. Total +113 across 2 files.

Reproducibility: yes. from source inspection: current main overwrites buffered function-call argument deltas with the final done.arguments value, so missing or empty done payloads can drop arguments or error. I did not run a live LM Studio repro in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Run one live LM Studio tool-call smoke before merge if maintainers want provider-specific confidence beyond the HTTP/SSE fixture.

Risk before merge

  • [P1] The PR proof exercises a real local HTTP/SSE fixture through streamSimpleOpenAIResponses, but not a live LM Studio model; maintainers may still want one live LM Studio tool-call smoke before landing.
  • [P1] The touched parser is shared by OpenAI Responses, Azure Responses, ChatGPT/Codex Responses mapping, and OpenAI-compatible proxy routes, so focused regression tests should be paired with normal CI before merge.

Maintainer options:

  1. Decide the mitigation before merge
    Land this narrow shared parser fix after maintainer review and CI, with an optional live LM Studio smoke if maintainers want provider-specific confirmation.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No repair job is needed because the review found no concrete patch defect; the remaining action is normal maintainer review, CI, and optional live LM Studio smoke.

Security
Cleared: The diff only changes shared stream parsing logic and colocated tests, with no dependency, workflow, secret, install, or supply-chain surface changes.

Review details

Best possible solution:

Land this narrow shared parser fix after maintainer review and CI, with an optional live LM Studio smoke if maintainers want provider-specific confirmation.

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

Yes from source inspection: current main overwrites buffered function-call argument deltas with the final done.arguments value, so missing or empty done payloads can drop arguments or error. I did not run a live LM Studio repro in this read-only review.

Is this the best way to solve the issue?

Yes: fixing the shared Responses stream parser is the narrow owner-boundary solution, while LM Studio-specific repair would duplicate generic OpenAI-compatible stream handling.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P1: The PR addresses a shipped regression where LM Studio-backed agents can lose required tool-call arguments, breaking real tool workflows.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from a local OpenAI-compatible HTTP/SSE server exercised through streamSimpleOpenAIResponses, which directly shows the retained tool-call path argument.

Label justifications:

  • P1: The PR addresses a shipped regression where LM Studio-backed agents can lose required tool-call arguments, breaking real tool workflows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output from a local OpenAI-compatible HTTP/SSE server exercised through streamSimpleOpenAIResponses, which directly shows the retained tool-call path argument.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from a local OpenAI-compatible HTTP/SSE server exercised through streamSimpleOpenAIResponses, which directly shows the retained tool-call path argument.
Evidence reviewed

PR surface:

Source +7, Tests +106. Total +113 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 4 +7
Tests 1 108 2 +106
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 119 6 +113

What I checked:

  • Current main still overwrites streamed arguments on done: On current main, processResponsesStream assigns event.arguments to currentBlock.partialJson and then calls event.arguments.startsWith(previousPartialJson), so a missing done.arguments can throw and an empty done.arguments can erase buffered delta JSON. (src/llm/providers/openai-responses-shared.ts:667, f8db47e34045)
  • PR guards the done payload before replacing the buffer: The patch converts done arguments to a string only when present, updates partialJson only for non-empty final arguments or an already-empty buffer, and only emits a synthetic delta when the final string extends the previous buffer. (src/llm/providers/openai-responses-shared.ts:667, 85f7f3a487a3)
  • Regression tests cover both LM Studio-style done shapes: The PR adds processResponsesStream tests for a done event that omits arguments and one that sends an empty string, both preserving the streamed read tool path argument. (src/llm/providers/openai-responses-shared.test.ts:355, 85f7f3a487a3)
  • Runtime path reaches the shared parser: runResponsesStreamLifecycle calls processResponsesStream, streamOpenAIResponses uses that lifecycle, and LM Studio wraps the registered streamSimple provider, so LM Studio models configured with openai-responses hit this shared parser. (src/llm/providers/openai-responses-shared.ts:503, f8db47e34045)
  • Dependency contract checked: OpenAI SDK 6.39.1 types declare ResponseFunctionCallArgumentsDoneEvent.arguments as a string, so the PR is deliberately tolerating OpenAI-compatible proxy divergence without changing the normal full-arguments done path. (package.json:1900, f8db47e34045)
  • History and ownership provenance: The current shared parser lines are blamed to a1f1895, while git log -S shows the older Responses function-call streaming path traces back through 4798e12. (src/llm/providers/openai-responses-shared.ts:656, a1f1895b1bf8)

Likely related people:

  • wsyjh8: Blame shows the current shared OpenAI Responses parser and its adjacent tests were added in a1f1895, which now owns the changed lines on main. (role: recent area contributor; confidence: high; commits: a1f1895b1bf8; files: src/llm/providers/openai-responses-shared.ts, src/llm/providers/openai-responses-shared.test.ts)
  • Vincent Koc: git log -S ties the earlier OpenAI Responses function-call streaming path to the provider transport adapter seam commit, which is relevant background for this parser behavior. (role: feature-history contributor; confidence: medium; commits: 4798e125f40c; files: src/agents/openai-transport-stream.ts)
  • Krasimir Kralev: Recent history shows adjacent OpenAI transport compatibility work in c45295c, making this a useful routing candidate for parser/runtime compatibility review. (role: recent adjacent contributor; confidence: medium; commits: c45295cc336e; files: src/agents/openai-transport-stream.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@ceo-nada

ceo-nada commented Jun 5, 2026

Copy link
Copy Markdown

Wow this was a crazy fast PR. Thank you!

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 5, 2026
@849261680

Copy link
Copy Markdown
Contributor Author

Wow this was a crazy fast PR. Thank you!

Glad to help!

@ceo-nada

ceo-nada commented Jun 6, 2026

Copy link
Copy Markdown

Is this going to get approved to merge to main?

@849261680

Copy link
Copy Markdown
Contributor Author

Is this going to get approved to merge to main?

Maybe, up to the maintainers.

@steipete steipete self-assigned this Jun 7, 2026
@steipete
steipete force-pushed the fix/90585-lmstudio-responses-tool-args branch from 5756531 to 85f7f3a Compare June 7, 2026 07:05
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 7, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. P1 High-priority user-facing bug, regression, or broken workflow. labels Jun 7, 2026
@steipete

steipete commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Maintainer verification for rebased head 85f7f3a.

Reviewed current and shipped behavior: main and v2026.6.1 overwrite buffered Responses tool-call arguments in src/llm/providers/openai-responses-shared.ts when response.function_call_arguments.done omits or empties arguments, while LM Studio Responses API is a documented supported local-provider path in docs/gateway/local-models.md.

Local proof:

  • OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/llm/providers/openai-responses-shared.test.ts extensions/lmstudio/src/stream.test.ts
  • pnpm exec oxfmt --check --threads=1 src/llm/providers/openai-responses-shared.ts src/llm/providers/openai-responses-shared.test.ts
  • node scripts/run-oxlint.mjs src/llm/providers/openai-responses-shared.ts src/llm/providers/openai-responses-shared.test.ts
  • pnpm tsgo:core
  • git diff --check origin/main...HEAD
  • pnpm changed:lanes --json (core + coreTests only)
  • /Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/main -> clean, no accepted/actionable findings

Real behavior proof: I also ran a local HTTP/SSE Responses fixture through streamSimpleOpenAIResponses with provider lmstudio; it made a real POST to /v1/responses, streamed a tool-call delta, then sent response.function_call_arguments.done without arguments. After the patch the final event stream ended with stopReason: "toolUse" and preserved the read tool call arguments as { "path": "docs/gateway/local-models.md" }.

CI: gh pr checks --watch --fail-fast is green for head 85f7f3a.

Not tested: a live LM Studio model run; no LM Studio server is reachable at 127.0.0.1:1234 in this environment.

@steipete
steipete merged commit 0543126 into openclaw:main Jun 7, 2026
176 of 179 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [REGRESSION] Tool calls with arguments arrive as empty objects when using LM Studio (openai-responses API).

3 participants