Skip to content

fix(compression): use extract_content_or_reasoning for thinking models (supersedes #19007)#23047

Open
shellybotmoyer wants to merge 1 commit into
NousResearch:mainfrom
shellybotmoyer:heartbeat/pr19007-resolved
Open

fix(compression): use extract_content_or_reasoning for thinking models (supersedes #19007)#23047
shellybotmoyer wants to merge 1 commit into
NousResearch:mainfrom
shellybotmoyer:heartbeat/pr19007-resolved

Conversation

@shellybotmoyer

Copy link
Copy Markdown
Contributor

This PR supersedes #19007 which had fallen behind origin/main and showed DIRTY merge state.

What changed

The original fix in #19007 changed agent/context_compressor.py line 871 from:

content = response.choices[0].message.content

to:

content = extract_content_or_reasoning(response)

Conflicts resolved

  • Import merge (<<<<<<< HEAD ... >>>>>>> in line 26): origin/main had added _is_connection_error to the same import line that the PR added extract_content_or_reasoning. Resolved by keeping both imports:
    from agent.auxiliary_client import call_llm, _is_connection_error, extract_content_or_reasoning

Original change description

When code reads an LLM response's text content, using response.choices[0].message.content silently returns empty string for thinking/reasoning models that put output in reasoning/reasoning_content fields. The fix uses the existing extract_content_or_reasoning() helper.

No other logic was changed.

Closes #19007 (supersedes)

When using thinking/reasoning models (DeepSeek v4, GLM-5.1, Qwen 3) via

Ollama 0.22+, the compressor reads only response.choices[0].message.content

which is empty when reasoning tokens consume the budget. The reasoning

field holds the actual summary content. Fixes NousResearch#19003.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists labels May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants