Skip to content

feat(openrouter): extract reasoning tokens and reasoning_details from responses.#954

Open
pocketarc wants to merge 1 commit intoprism-php:mainfrom
pocketarc:feature/openrouter-reasoning
Open

feat(openrouter): extract reasoning tokens and reasoning_details from responses.#954
pocketarc wants to merge 1 commit intoprism-php:mainfrom
pocketarc:feature/openrouter-reasoning

Conversation

@pocketarc
Copy link
Contributor

At the moment, the OpenRouter provider discards reasoning content from non-streaming responses. Streaming handles plaintext reasoning deltas, but reasoning, reasoning_details, and thoughtTokens were all lost in non-streaming mode. Structured reasoning metadata (reasoning_details) was ignored everywhere.

I've added an ExtractsReasoning trait for non-streaming extraction, an OpenRouterStreamState to track reasoning_details during streaming, updated MessageMap to preserve reasoning across tool-calling turns, updated the documentation, and included tests.

I also verified with real API calls against Claude, GPT-5, Gemini, and DeepSeek R1.

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