Skip to content

Fix provider usage detail object initialization in provider_chat_model - #1

Open
slothsh wants to merge 1 commit into
ouxianghui:mainfrom
slothsh:main
Open

slothsh wants to merge 1 commit into
ouxianghui:mainfrom
slothsh:main

Conversation

@slothsh

@slothsh slothsh commented Sep 19, 2026

Copy link
Copy Markdown

Overview

When using an OpenAI-compatible model through OpenRouter, successful responses containing usage details such as prompt_tokens_details and completion_tokens_details caused the provider model to fail during response processing:

cannot use operator[] with a string argument with an array

This prevented OpenRouter tool-calling workflows from continuing after the model returned a valid response.

Solution

Explicitly initialize TokenUsage::details_ as a JSON object before storing provider-specific usage fields:

UsageMetadata usage;
usage.tokens_.details_ = nlohmann::json::object();

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