fix: strip think blocks from reasoning field in extract_content_or_reasoning - #17797
fix: strip think blocks from reasoning field in extract_content_or_reasoning#17797Ifkellx wants to merge 2 commits into
Conversation
… from backup/minimax-20260430)
…asoning - extract_content_or_reasoning now strips <think> blocks from message.reasoning and reasoning_details before returning, fixing session titles that showed raw think block content - title_generator now uses extract_content_or_reasoning instead of direct .content access, ensuring consistent handling across all response types - 4 new tests covering think block stripping in content, reasoning field, and reasoning_details summary
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the structured-reasoning title path. The premise remains valid on current main: agent/title_generator.py:90 reads only message.content, while agent/auxiliary_client.py:7006-7026 already defines the structured-reasoning fallback.
Problems
- The added fallback at PR
agent/auxiliary_client.py:3682returnsjoined.strip()when tag removal yields an empty string. A reasoning field containing only `` therefore still leaks the raw block. - The title fix is coupled to unrelated MiniMax Coding Plan vision, provider, and web-search work (
agent/auxiliary_client.py:2435,tools/web_tools.py:998in the PR diff). Current main has a user model-provider plugin discovery surface atproviders/__init__.py:163-165.
Suggested changes
- Split out the focused title/extractor/test change.
- Return the cleaned structured-reasoning value even when empty, and test reasoning containing only a think block.
- Reuse the canonical scrubber behavior used by
agent/title_generator.py:97-98.
Automated hermes-sweeper review.
| return re.sub( | ||
| r"<(?:think|thinking|reasoning|thought|REASONING_SCRATCHPAD)>" | ||
| r".*?" | ||
| r"</(?:think|thinking|reasoning|thought|REASONING_SCRATCHPAD)>", |
There was a problem hiding this comment.
When joined contains only a paired think block, re.sub(...).strip() is empty and this fallback returns the original raw block. Return the cleaned value instead, and add coverage for reasoning that is only ``.
|
Thanks for the contribution. Closing on policy: Hermes does not post-process or repair model output. Extracting titles out of the The bundled MiniMax Coding Plan vision client is a separate feature that shouldn't ride in a title-fix PR — if you want to pursue it, please open it as its own focused PR so it can be evaluated on its own merits. |
Summary
Fixes session titles showing raw think block content instead of the generated title.
Changes
extract_content_or_reasoning: now strips<think>blocks frommessage.reasoningandreasoning_detailsbefore returningtitle_generator: usesextract_content_or_reasoning()instead of direct.contentaccess for consistent handlingRoot cause
When the auxiliary model returned the title in the
message.reasoningstructured field instead ofmessage.content, the fallback path returned raw reasoning text including<think>blocks without cleaning them.Testing
python -m pytest tests/tools/test_llm_content_none_guard.py tests/agent/test_title_generator.py -v