Skip to content

fix: auto reasoning effort for qwen max, close #1751#1765

Merged
looplj merged 1 commit into
unstablefrom
dev-tmp
Jun 2, 2026
Merged

fix: auto reasoning effort for qwen max, close #1751#1765
looplj merged 1 commit into
unstablefrom
dev-tmp

Conversation

@looplj

@looplj looplj commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@greptile-apps

greptile-apps Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where the auto-reasoning-effort middleware incorrectly parsed Qwen model names ending in -max (e.g., qwen3.7-max, qwen/qwen3-max) as a base model plus a max reasoning-effort suffix, stripping the suffix and sending the wrong model name downstream.

  • Adds an isQwenMaxModel guard called immediately after the effort is identified as "max", which strips any namespace prefix and checks for the qwen prefix; if matched, the model is left untouched.
  • Adds two splitAutoReasoningEffortModel unit tests and one middleware integration test covering plain and namespaced Qwen-max model strings.

Confidence Score: 4/5

Safe to merge — the change is a narrowly scoped guard that only activates for Qwen model names ending in -max, leaving all other model handling untouched.

The fix is correct and well-tested for the reported cases. The only notable issue is a redundant HasSuffix check inside isQwenMaxModel that can never be false when the function is called, making that branch dead code — it does not affect correctness.

No files require special attention; both changed files are straightforward and the logic is easy to follow.

Important Files Changed

Filename Overview
internal/server/orchestrator/auto_reasoning_effort.go Adds Qwen-specific guard in splitAutoReasoningEffortModel and a new isQwenMaxModel helper to prevent -max suffix from being incorrectly interpreted as a reasoning-effort token on Qwen models.
internal/server/orchestrator/auto_reasoning_effort_test.go Adds two unit tests for splitAutoReasoningEffortModel and one middleware integration test covering plain and namespaced Qwen-max model names.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[OnInboundLlmRequest] --> B{AutoReasoningEffort\nenabled?}
    B -- No --> Z[Return request unchanged]
    B -- Yes --> C[splitAutoReasoningEffortModel]
    C --> D{last dash exists\n& not trailing?}
    D -- No --> Z
    D -- Yes --> E{effort in\nsupportedEfforts?}
    E -- No --> Z
    E -- Yes --> F{effort == max &&\nisQwenMaxModel?}
    F -- Yes --> Z
    F -- No --> G{base model\nnot empty?}
    G -- No --> Z
    G -- Yes --> H[Set Model = base\nSet ReasoningEffort = effort]
    H --> I[Return modified request]

    subgraph isQwenMaxModel
        J[Lowercase + trim full string] --> K[Strip namespace prefix\nafter last slash]
        K --> L{HasPrefix qwen?}
        L -- Yes --> M[return true]
        L -- No --> N[return false]
    end
Loading

Reviews (1): Last reviewed commit: "fix: auto reasoning effort for qwen max,..." | Re-trigger Greptile

Comment on lines +88 to +99
func isQwenMaxModel(model string) bool {
normalized := strings.ToLower(strings.TrimSpace(model))
if !strings.HasSuffix(normalized, "-max") {
return false
}

if lastSlash := strings.LastIndex(normalized, "/"); lastSlash >= 0 {
normalized = normalized[lastSlash+1:]
}

return strings.HasPrefix(normalized, "qwen")
}

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.

P2 The HasSuffix(normalized, "-max") check is always true at this point: isQwenMaxModel is only called when effort == "max", which was extracted from the last --delimited segment, meaning the original (and lowercased) model string already ends with -max. The guard can be dropped without changing behaviour.

Suggested change
func isQwenMaxModel(model string) bool {
normalized := strings.ToLower(strings.TrimSpace(model))
if !strings.HasSuffix(normalized, "-max") {
return false
}
if lastSlash := strings.LastIndex(normalized, "/"); lastSlash >= 0 {
normalized = normalized[lastSlash+1:]
}
return strings.HasPrefix(normalized, "qwen")
}
func isQwenMaxModel(model string) bool {
normalized := strings.ToLower(strings.TrimSpace(model))
if lastSlash := strings.LastIndex(normalized, "/"); lastSlash >= 0 {
normalized = normalized[lastSlash+1:]
}
return strings.HasPrefix(normalized, "qwen")
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@looplj looplj merged commit 23ae5f0 into unstable Jun 2, 2026
5 checks passed
junjiangao pushed a commit to junjiangao/axonhub that referenced this pull request Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant