Repository navigation
fix: treat model auto as runtime default - #181
Conversation
WalkthroughThis PR implements handling of the "auto" model selector to resolve issue ChangesModel Auto-Normalization Feature
Symlink Handling Fix
Sequence Diagram: ACP Client Session Model SetupsequenceDiagram
participant Test
participant Client as ACP Client
participant Agent as Helper Agent
Test->>Client: CreateSession(ClientConfig.Model="explicit-id")
activate Client
Client->>Client: resolveModel(normalized="explicit-id")
Client->>Agent: SetSessionModel(model_id="explicit-id")
activate Agent
Agent->>Agent: Mark modelSet=true
Agent-->>Client: SetSessionModelResponse
deactivate Agent
Client->>Agent: Prompt(...)
activate Agent
Agent->>Agent: Check modelSet==true
Agent-->>Client: PromptResponse
deactivate Agent
Client-->>Test: Success
deactivate Client
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
| Filename | Overview |
|---|---|
| internal/core/agent/registry_launch.go | Extracts normalizeRequestedModel() helper that maps 'auto' (case-insensitive, trimmed) to empty string before alias resolution, causing resolveModel() to fall back to spec.DefaultModel — preventing literal 'auto' from reaching SetSessionModel on non-bootstrap ACPs. |
| internal/core/agent/client_test.go | Adds two integration tests verifying 'auto' model suppresses SetSessionModel on non-bootstrap ACP and explicit models (e.g. 'composer-2') still call SetSessionModel correctly; extends helper infrastructure with RejectSessionModel and ExpectedSessionModelID sentinel fields. |
| internal/core/agent/registry_test.go | Adds unit test covering resolveModel/ResolveRuntimeModel for multiple IDEs and input variants of 'auto' (trimmed, uppercase, lowercase) confirming spec.DefaultModel is returned instead of the literal string. |
| scripts/link-skills.sh | Fixes dangling-symlink detection in link_skill(): outer guard now includes [ -L "$target_path" ] so stale symlinks pointing to deleted targets are caught and re-linked instead of causing a 'File exists' ln error. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["cfg.Model input (e.g. 'auto', ' AUTO ', 'composer-2')"] --> B["normalizeRequestedModel()"]
B --> C{EqualFold 'auto'?}
C -- yes --> D["selected = ''"]
C -- no --> E["selected = trimmed value"]
D --> F["selected = spec.DefaultModel"]
E --> G["modelprovider.ResolveAlias(selected)"]
F --> G
G --> H["normalizeRuntimeModel()"]
H --> I["requestedModel"]
I --> J{requestedModel == startModel?}
J -- yes --> K["Skip SetSessionModel"]
J -- no --> L["Call SetSessionModel(requestedModel)"]
Reviews (1): Last reviewed commit: "fix: treat model auto as runtime default" | Re-trigger Greptile
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/core/agent/registry_launch.go (1)
173-179: ⚡ Quick winAdd function documentation.
The exported helper
normalizeRequestedModelshould have a doc comment explaining its purpose and behavior, particularly the case-insensitive "auto" conversion to empty string.📝 Proposed documentation
+// normalizeRequestedModel preprocesses the user-provided model name by trimming +// whitespace and converting the case-insensitive literal "auto" to an empty string, +// enabling fallback to the runtime's default model. func normalizeRequestedModel(modelName string) string {As per coding guidelines: "Keep comments short and focused on intent, invariants, or protocol edge cases."
🤖 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/core/agent/registry_launch.go` around lines 173 - 179, Add a short doc comment for normalizeRequestedModel explaining its purpose: it trims whitespace from the input modelName and returns the cleaned name, with a special case that treats the string "auto" case-insensitively as meaning "no specific model" and returns an empty string; mention that comparison is case-insensitive and that the function returns the trimmed model name otherwise.
🤖 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.
Nitpick comments:
In `@internal/core/agent/registry_launch.go`:
- Around line 173-179: Add a short doc comment for normalizeRequestedModel
explaining its purpose: it trims whitespace from the input modelName and returns
the cleaned name, with a special case that treats the string "auto"
case-insensitively as meaning "no specific model" and returns an empty string;
mention that comparison is case-insensitive and that the function returns the
trimmed model name otherwise.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5405d1f0-5681-458e-9c12-556606d398ff
📒 Files selected for processing (4)
internal/core/agent/client_test.gointernal/core/agent/registry_launch.gointernal/core/agent/registry_test.goscripts/link-skills.sh
Summary
Verification
Fixes #177
Summary by CodeRabbit
Bug Fixes
Tests