Skip to content

open_ai: Fix parsing response if token use info is unspecified#55919

Merged
benbrandt merged 1 commit into
zed-industries:mainfrom
marius851000:openai_do_not_expect_complete_token_use_info
May 17, 2026
Merged

open_ai: Fix parsing response if token use info is unspecified#55919
benbrandt merged 1 commit into
zed-industries:mainfrom
marius851000:openai_do_not_expect_complete_token_use_info

Conversation

@marius851000

Copy link
Copy Markdown
Contributor

I tried to use google cloud to test gemma4 and compare with the result of ollama. it had response such as

{"choices":[{"delta":{"content":"Hello","reasoning_content":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null,"matched_stop":null}],"created":1778081610,"id":"KV_7adz7Ov20xN8Py-angQ8","model":"google/gemma-4-26b-a4b-it-maas","object":"chat.completion.chunk","usage":{"extra_properties":{"google":{"traffic_type":"ON_DEMAND"}}}}

(notice that, while "usage" is present, it does not have any of the usual value)

Eventually, I had some more issue when parsing the response (unrelated to this), so I decided to try the google ai endpoint, with its own set of issue.

Those simple change should only loosen the accepted format, so no new compatibility error are expected (but I haven’t tried with other provider)

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist (no change)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Improved open-ai compatibility when token usage info is absent

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 6, 2026
@github-actions github-actions Bot added the community champion Issues filed by our amazing community champions! 🫶 label May 6, 2026
@maxdeviant maxdeviant changed the title openai api: Fix parsing response if token use info is unspecified open_ai: Fix parsing response if token use info is unspecified May 6, 2026
@ChristopherBiscardi ChristopherBiscardi added the area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features label May 6, 2026
@benbrandt benbrandt enabled auto-merge May 17, 2026 19:38
@benbrandt benbrandt self-assigned this May 17, 2026
@benbrandt benbrandt added this pull request to the merge queue May 17, 2026
Merged via the queue into zed-industries:main with commit 53c9109 May 17, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants