fix(agent): retry title generation with a larger budget for unconfigured reasoning models - #3387
Open
albatrossflyon-coder wants to merge 1 commit into
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3284.
Root cause
GenerateTitlealready bumps the output-token budget for models flaggedCatwalkCfg.CanReason(40 →DefaultMaxTokens), specifically so a thinking model doesn't burn its whole budget on hidden reasoning content before producing a title. It also tries a/no_thinkprompt hack for templates that respect it.CanReasoncomes from static model metadata (Catwalk's known-model registry). A hand-configured custom/local provider — like a local llama.cpp server serving a thinking-capable model — has no such metadata unless the user explicitly sets it. If it's unset, the model still reasons by its own chat template default (the/no_thinkhack only works for templates that specifically respect that convention) — crush just doesn't know to give it room. So it burns the tiny 40-token budget entirely on hidden reasoning, produces no title text, and every attempt (small model, then large model) falls through to the"Untitled Session"fallback — matching this issue's exact symptom.Fix
Detect this directly instead of depending on correct prior configuration: if a title attempt hits
FinishReasonLengthand the response contains reasoning content even thoughCanReasonwas false, that's a template-agnostic signal the model needs more room regardless of what its config declares. Retry that same attempt once with a larger budget (DefaultMaxTokens, or a 2000-token fallback if that's also unset for a custom model) before moving to the next model attempt.Extracted the decision into
shouldRetryTitleWithLargerBudgetso it's directly unit-testable without mocking the fullStream/Agentmachinery.Testing
TestShouldRetryTitleWithLargerBudget(4 cases: unconfigured reasoning model hitting the limit → retry; already-bumped budget → no further retry; hit limit with no reasoning content → not a thinking-budget problem, no retry; finished normally → no retry).go build ./...andgo vet ./internal/agent/...clean.go test ./internal/agent/... -run "^$"compiles clean across all subpackages.