Skip to content

openclaw: reconcile final ai-gendone tool calls by id and drop cut-off calls - #438

Open
Pybsama wants to merge 1 commit into
Nehanth:mainfrom
Pybsama:fix/openclaw-stream-final-calls-reconciliation
Open

Pybsama wants to merge 1 commit into
Nehanth:mainfrom
Pybsama:fix/openclaw-stream-final-calls-reconciliation

Conversation

@Pybsama

@Pybsama Pybsama commented Dec 4, 2026

Copy link
Copy Markdown

Summary

Reconciles packages/openclaw/src/stream.js final answer.calls against streamed toolCall blocks by call id (instead of positional index):

  • Unstreamed final calls: When ai-gendone.calls includes completed calls that were not preceded by ai-call streaming events, append them to message.content and emit toolcall_start, toolcall_delta, and toolcall_end so stopReason: "toolUse" always matches actual toolCall blocks in message.content (consistent with cli/lib/responses.js).
  • Cut-off / dropped streamed calls: When a streamed call is truncated at max_tokens (answer.open, absent from answer.calls) or dropped/capped in Ask.finish, remove the uncompleted toolCall entry from message.content so convert.js does not replay a phantom {} call on subsequent turns.
  • Id-based reconciliation: Match streamed calls by c.id rather than array index i, preventing a different final tool at the same index (for which Ask.finish mints a new id) from keeping the stale streamed tool name/id while overwriting its arguments.

Verification

  • Added 3 regression tests in packages/openclaw/test/plugin_test.mjs (all 3 reproduced the bugs and failed before the fix):
    • node --check packages/openclaw/src/stream.js && node --check packages/openclaw/test/plugin_test.mjs — passed
    • npm run test:packages — 216 pass, 0 fail, 6 skipped
    • npm run test:runtime — passed

@Pybsama
Pybsama requested a review from Nehanth as a code owner December 4, 2026 03:07
@vercel

vercel Bot commented Dec 4, 2026

Copy link
Copy Markdown

@Pybsama is attempting to deploy a commit to the nehanth's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant