Skip to content

fix(runner): normalize missing tool call IDs#1958

Merged
HAYDEN-OAI merged 3 commits into
mainfrom
dev/hayden/pr-1946-review
Jun 25, 2026
Merged

fix(runner): normalize missing tool call IDs#1958
HAYDEN-OAI merged 3 commits into
mainfrom
dev/hayden/pr-1946-review

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

Summary

  • carries forward fix: handle missing tool_call.id in runTools for providers #1946 while preserving the original @anishesg commit and explicit co-author credit
  • generates a unique fallback ID when an OpenAI-compatible provider omits a tool call ID or returns an empty string
  • normalizes IDs before completions are stored or emitted, keeping assistant tool calls and tool-result messages paired
  • handles both non-streaming and streaming runners, including parallel calls to the same function

Context

GitHub rejected the maintainer push to the organization-owned fork even though the PR reports maintainer edits as enabled. This integration branch therefore merges the original PR commit and builds the corrected implementation on top of it rather than recreating the contribution separately.

Validation

  • pnpm exec jest tests/lib/ChatCompletionRunFunctions.test.ts --runInBand
  • pnpm exec tsc --noEmit
  • focused ESLint and Prettier checks
  • pnpm build

Closes #1528

anishesg and others added 3 commits June 19, 2026 21:46
Some providers do not populate the `tool_call.id` field when returning tool calls, or may set it to an empty string. When the SDK's `AbstractChatCompletionRunner._runTools()` method constructs tool result messages to send back to the API, it uses this empty or missing `tool_call_id`, which causes the API to reject the request with a 400 status code.

Signed-off-by: anish <anishesg@users.noreply.github.com>
# Conflicts:
#	src/lib/AbstractChatCompletionRunner.ts
Co-authored-by: anish <anishesg@users.noreply.github.com>
@HAYDEN-OAI HAYDEN-OAI merged commit 6371623 into main Jun 25, 2026
19 of 20 checks passed
@stainless-app stainless-app Bot mentioned this pull request Jun 25, 2026
@faizanallex

Copy link
Copy Markdown

Thank You

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.

runTools giving BadRequestError: 400 status code (no body)

4 participants