Skip to content

fix(go-models): normalize Qwen reasoning families - #15735

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
oktofeesh1:codex/qwen-reasoning-family
Jun 8, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
oktofeesh1:codex/qwen-reasoning-family

Conversation

@oktofeesh1

Copy link
Copy Markdown
Contributor

Summary

Normalizes Qwen model-family names before reasoning extraction so provider-prefixed Qwen models use the existing <think>...</think> fallback.

What changed

  • Normalize model family strings by trimming whitespace, lowercasing, and removing provider prefixes.
  • Treat qwen3-* and qwen3.* variants as the qwen3 reasoning family.
  • Add regression tests for plain, versioned, provider-prefixed, and mixed-case Qwen families.

Why

Provider-prefixed models such as qwen/qwen3-8b and qwen/qwen3.5-4b previously did not match the exact qwen3 family check, so reasoning content embedded in <think>...</think> stayed in the answer text.

Fixes #15611

Validation

  • go test ./internal/entity/models -run 'TestGetThinkingAndAnswer'
  • go test ./internal/entity/models -run '^$'
  • go vet ./internal/entity/models
  • git diff --check

Notes

  • Full go test ./internal/entity/models is currently limited by pre-existing API-key validation expectation failures in unrelated model-driver tests.
  • CodeRabbit hit the local review usage limit before returning findings, so validation continued with local tests and vet.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jun 7, 2026
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 19dd60fa-1ebc-475b-80d8-1bbccb7860de

📥 Commits

Reviewing files that changed from the base of the PR and between 3f8e609 and f72431d.

📒 Files selected for processing (2)
  • internal/entity/models/common.go
  • internal/entity/models/common_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/entity/models/common_test.go
  • internal/entity/models/common.go

📝 Walkthrough

Walkthrough

NormalizeModelFamily tightens qwen3-family detection to exact qwen3 or qwen3-/qwen3. prefixes; tests expand Qwen variants, change thinking extraction expectation to "plan", add an unknown-family test, and extend nil-input assertions for GetThinkingAndAnswer.

Changes

Thinking extraction & normalization

Layer / File(s) Summary
Model family normalization logic
internal/entity/models/common.go
Narrow qwen3-family recognition: treat family as qwen3 only when exactly qwen3 or prefixed with qwen3- or qwen3. (replaces broader HasPrefix check).
Normalize and thinking extraction tests
internal/entity/models/common_test.go
Expand NormalizeModelFamily test cases for hyphen/dot/provider/case variants; update Qwen think extraction expectations to "plan", add TestGetThinkingAndAnswerLeavesUnknownModelFamiliesUnchanged, and extend nil-input tests to cover pointer preservation and nil handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ci, ☯️ refactor, size:M

Suggested reviewers

  • Haruko386

Poem

🐰 I trim names tidy, lower and clear,
qwen3 found when dotted, hyphenated, or near.
Nil pointers hold steady, unknowns left the same,
Tests hop to confirm each exact little change.
A rabbit's small cheer for code that's now tame.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: normalizing Qwen reasoning families to handle provider-prefixed and variant model names.
Description check ✅ Passed The description provides clear problem context, outlines what changed, explains the rationale, and includes validation steps, though the PR template sections are not explicitly labeled.
Linked Issues check ✅ Passed The PR implements all key objectives from #15611: normalizes model-family detection, handles provider-prefixed names, treats qwen3-* and qwen3.* variants consistently, and adds regression tests.
Out of Scope Changes check ✅ Passed All changes are scoped to reasoning extraction in internal/entity/models; no unrelated model discovery, routing, or other subsystems were altered.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/entity/models/common_test.go (1)

5-38: ⚡ Quick win

Add tests for nil-input and qwen3-boundary behavior introduced by this PR.

Please add cases for (nil, &content), (&modelType, nil), and a non-target prefix like "qwen30-foo" to lock in the intended normalization contract and prevent regressions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/common_test.go` around lines 5 - 38, Add tests to
cover nil-input and qwen3-boundary behavior for GetThinkingAndAnswer: add test
cases for (nil, &content) and (&modelType, nil) verifying they return expected
nil/unchanged behavior, and add a case with a non-target prefix like
"qwen30-foo" to ensure it is not normalized to qwen3; reference the existing
TestGetThinkingAndAnswerNormalizesQwenModelFamilies and
TestGetThinkingAndAnswerLeavesUnknownModelFamiliesUnchanged tests and extend
them (or add a new test) to assert the correct pointers/values when modelType is
nil, content is nil, and when modelType is "qwen30-foo".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/entity/models/common.go`:
- Around line 38-40: The current prefix check for modelFamily ("qwen3") is too
broad and can misclassify other families; update the condition in the function
that returns the family (the code using the modelFamily variable) to match only
exact "qwen3" or bounded forms by checking modelFamily == "qwen3" ||
strings.HasPrefix(modelFamily, "qwen3-") || strings.HasPrefix(modelFamily,
"qwen3.") so only exact or hyphen/dot-suffixed variants are classified as qwen3.

---

Nitpick comments:
In `@internal/entity/models/common_test.go`:
- Around line 5-38: Add tests to cover nil-input and qwen3-boundary behavior for
GetThinkingAndAnswer: add test cases for (nil, &content) and (&modelType, nil)
verifying they return expected nil/unchanged behavior, and add a case with a
non-target prefix like "qwen30-foo" to ensure it is not normalized to qwen3;
reference the existing TestGetThinkingAndAnswerNormalizesQwenModelFamilies and
TestGetThinkingAndAnswerLeavesUnknownModelFamiliesUnchanged tests and extend
them (or add a new test) to assert the correct pointers/values when modelType is
nil, content is nil, and when modelType is "qwen30-foo".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a1019f23-b91e-4fe3-95fa-b634f6de566c

📥 Commits

Reviewing files that changed from the base of the PR and between 5a04ac0 and 0038c9b.

📒 Files selected for processing (2)
  • internal/entity/models/common.go
  • internal/entity/models/common_test.go

Comment thread internal/entity/models/common.go Resolved
@oktofeesh1
oktofeesh1 force-pushed the codex/qwen-reasoning-family branch from 0038c9b to 5ab5efb Compare June 7, 2026 12:14
@oktofeesh1

Copy link
Copy Markdown
Contributor Author

Hi @Haruko386 @JinHai-CN this is ready for review 👍

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oktofeesh1
oktofeesh1 force-pushed the codex/qwen-reasoning-family branch from 5ab5efb to 3f8e609 Compare June 8, 2026 06:06
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 8, 2026
@oktofeesh1

Copy link
Copy Markdown
Contributor Author

@oktofeesh1
oktofeesh1 requested a review from Haruko386 June 8, 2026 06:07

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oktofeesh1
I just never see this model before, for real.
At least I never saw any model start wit qwen30

I will be happy if you could tell me where i can find it

Comment thread internal/entity/models/common_test.go Resolved
@oktofeesh1
oktofeesh1 force-pushed the codex/qwen-reasoning-family branch from 3f8e609 to f72431d Compare June 8, 2026 07:14
@oktofeesh1

Copy link
Copy Markdown
Contributor Author

Thanks, you are right. qwen30-foo was only a synthetic boundary fixture from the earlier CodeRabbit suggestion; it is not a real model name, and using it made the test confusing.

I removed those qwen30 cases and replaced them with real non-qwen3 Qwen names already present in this repo config: qwen-plus and qwen/qwen2.5-32b-instruct. The test still verifies that non-qwen3 families are left unchanged by GetThinkingAndAnswer, while the qwen3 exact / hyphen / dot cases continue to cover the intended matching behavior.

Validation passed with go test ./internal/entity/models -run 'TestNormalizeModelFamily|TestGetThinkingAndAnswer' -count=1, go test ./internal/entity/models -run '^$' -count=1, go vet ./internal/entity/models, and git diff --check.

@oktofeesh1
oktofeesh1 requested a review from Haruko386 June 8, 2026 07:17
@Haruko386 Haruko386 added the ci Continue Integration label Jun 8, 2026
@Haruko386
Haruko386 marked this pull request as draft June 8, 2026 08:06
@Haruko386
Haruko386 marked this pull request as ready for review June 8, 2026 08:06

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 8, 2026
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (220ee9d) to head (f72431d).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15735   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 6fc3955 into infiniflow:main Jun 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Normalize model-family detection for reasoning extraction

3 participants