Skip to content

fix: support reasoning models in title generation#20266

Open
gzsiang wants to merge 2 commits into
NousResearch:mainfrom
gzsiang:fix/title-generation-reasoning-support
Open

fix: support reasoning models in title generation#20266
gzsiang wants to merge 2 commits into
NousResearch:mainfrom
gzsiang:fix/title-generation-reasoning-support

Conversation

@gzsiang

@gzsiang gzsiang commented May 5, 2026

Copy link
Copy Markdown

Description

Fixes #18529

title_generator.py was reading response.choices[0].message.content directly, which doesn't work for reasoning models (e.g. Qwen3.5, deepseek) that output thinking content to reasoning_content instead of content.

Changes

  • Import extract_content_or_reasoning from auxiliary_client
  • Add _extract_title_from_reasoning() function that:
    1. Looks for final selection patterns (Select/Choose/Best option)
    2. Extracts quoted title candidates from reasoning text
    3. Falls back to last plausible phrase
    4. Ultimate fallback to raw output
  • Use extract_content_or_reasoning() to get raw output before extracting title

Files Changed

  • agent/title_generator.py (+65, -2)

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder labels May 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #18643 (and overlaps with #19008). All three PRs fix the same root cause reported in #18529: title_generator.py reads response.choices[0].message.content directly instead of using extract_content_or_reasoning(), breaking title generation for reasoning models.

@gzsiang gzsiang force-pushed the fix/title-generation-reasoning-support branch 5 times, most recently from d4c674a to 98bfaad Compare May 14, 2026 17:45
@gzsiang gzsiang force-pushed the fix/title-generation-reasoning-support branch from cf6f416 to 8dd07a3 Compare May 16, 2026 15:31
gzsiang added 2 commits May 20, 2026 02:33
When the title_generation LLM uses --reasoning-format (e.g. deepseek),
the model outputs to reasoning_content instead of content. The original
code only read content, resulting in empty titles.

Changes:
- Import extract_content_or_reasoning to handle reasoning models
- Add _extract_title_from_reasoning() to extract clean titles from
  reasoning traces (looks for quoted options, best option selection,
  or falls back to last plausible phrase)
- Clean up reasoning artifacts (bullet points, char counts, etc.)
The fallback was doing raw.strip()[:80], which produced exactly 80
characters. The subsequent len(title) > 80 check didn't trigger,
so the trailing '...' was never added. Let generate_title() handle
the 80-char limit consistently.
@gzsiang gzsiang force-pushed the fix/title-generation-reasoning-support branch from 8dd07a3 to 1678d6f Compare May 19, 2026 18:34
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.

[Bug]: title_generator.py read response.choices[0].message.content directly instead of use extract_content_or_reasoning() to extract <thinking> tag

2 participants