-
Notifications
You must be signed in to change notification settings - Fork 0
feat: unify reasoning_content + thinking_blocks across providers (v0.4.9) #14
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,12 +231,23 @@ def _build_model_response(self, resp: dict[str, Any], model: str) -> ModelRespon | |
| arguments=fc.get("arguments", ""), | ||
| ) | ||
|
|
||
| # ``reasoning_content`` is the de-facto field name used by | ||
| # DeepSeek-R1, GLM-4.5+, Groq's DeepSeek/Qwen-thinking models, | ||
| # Cerebras, Together, Fireworks, and any OpenAI-compat host | ||
| # serving a reasoning model. ``reasoning`` is the alias | ||
| # OpenAI ships on the chat-completions endpoint for o-series | ||
| # responses; we accept either and normalise to one field. | ||
| reasoning_content = message_data.get("reasoning_content") or message_data.get( | ||
| "reasoning" | ||
| ) | ||
|
|
||
| message = Message( | ||
| role=message_data.get("role", "assistant"), | ||
| content=message_data.get("content"), | ||
| tool_calls=tool_calls, | ||
| function_call=function_call, | ||
| refusal=message_data.get("refusal"), | ||
| reasoning_content=reasoning_content, | ||
| ) | ||
|
|
||
| choices.append( | ||
|
|
@@ -303,6 +314,8 @@ def parse_stream_event(self, data: str, model: str) -> StreamChunk | None: | |
| content=delta_data.get("content"), | ||
| tool_calls=tool_calls, | ||
| function_call=delta_data.get("function_call"), | ||
| reasoning_content=delta_data.get("reasoning_content") | ||
| or delta_data.get("reasoning"), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Falsy
|
||
| ) | ||
|
|
||
| choices.append( | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Streaming silently drops redacted_thinking blocks
Medium Severity
The Anthropic streaming handler in
parse_stream_eventhandlescontent_block_startfortype=="thinking"but silently dropstype=="redacted_thinking"blocks (returnsNone). The non-streaming_build_model_responsecorrectly preservesredacted_thinkingblocks. Anthropic's streaming protocol does emitcontent_block_startwithtype: "redacted_thinking", and these blocks must be preserved unchanged for multi-turn conversation history. Additionally,stream_chunk_builderhardcodestype="thinking"for all assembled blocks, making it impossible to representredacted_thinkingeven if the adapter were to emit them.Additional Locations (1)
arcllm/core.py#L679-L688Reviewed by Cursor Bugbot for commit b5552ff. Configure here.