Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(openai): filter function_call blocks in token counting#34396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sujalmh wants to merge3 commits intolangchain-ai:master
base:master
Choose a base branch
Loading
fromsujalmh:fix/token-counter-function-call

Conversation

@sujalmh
Copy link

The Responses API returns messages withfunction_call content blocks which causeget_num_tokens_from_messages to raise aValueError: Unrecognized content block type. This occurs because the token counter internally uses the chat/completions format logic, which does not recognize these blocks.

This PR updates_format_message_content to filter outfunction_call blocks when formatting messages for the chat/completions API (which includes the token counter). These blocks are redundant for token counting as the actual tool calls are already handled via the separatetool_calls field, ensuring accurate counts without errors.

Fixes#34378

Breaking Changes: None.

@github-actionsgithub-actionsbot added integrationPR made that is related to a provider partner package integration openai`langchain-openai` package issues & PRs fixFor PRs that implement a fix labelsDec 16, 2025
@sujalmhsujalmh marked this pull request as ready for reviewDecember 16, 2025 19:56
@codspeed-hq
Copy link

codspeed-hqbot commentedDec 16, 2025
edited
Loading

CodSpeed Performance Report

Merging#34396 willnot alter performance

Comparingsujalmh:fix/token-counter-function-call (c21a249) withmaster (71778cb)

Summary

✅ 6 untouched
⏩ 28 skipped1

Footnotes

  1. 28 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase,click here and archive them to remove them from the performance reports.

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

Reviewers

@ccurmeccurmeAwaiting requested review from ccurmeccurme is a code owner

@mdrxymdrxyAwaiting requested review from mdrxymdrxy is a code owner

1 more reviewer

@sargismarkosyansargismarkosyansargismarkosyan left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

fixFor PRs that implement a fixintegrationPR made that is related to a provider partner package integrationopenai`langchain-openai` package issues & PRs

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

OpenAI token counter throws error if responses api content includes function_call

2 participants

@sujalmh@sargismarkosyan

[8]ページ先頭

©2009-2025 Movatter.jp