fix: added claude haiku support in backend rust#7188
fix: added claude haiku support in backend rust#7188shodown96 wants to merge 2 commits intoBasedHardware:mainfrom
Conversation
Greptile SummaryThis PR fixes a
Confidence Score: 4/5Safe to merge — the core fix (model routing and pricing) is correct and the only concern is a test assertion placed in the wrong test function. The model route entries and pricing values look correct. The one rough edge is that the omi-haiku assertion was dropped into test_resolve_model_unknown rather than a dedicated test, and it does not verify the upstream_model value the way every other route test does — so a future regression would go undetected. The test block in desktop/Backend-Rust/src/routes/chat_completions.rs around test_resolve_model_unknown deserves a second look to verify the assertion is moved and strengthened before merging. Important Files Changed
Sequence DiagramsequenceDiagram
participant App as Swift Desktop App
participant Proxy as Rust Proxy /v2/chat/completions
participant Resolver as resolve_model()
participant Cost as model_cost()
participant Anthropic as Anthropic API
App->>Proxy: POST /v2/chat/completions {model: "claude-haiku-4-5-20251001"}
Proxy->>Resolver: resolve_model("claude-haiku-4-5-20251001")
note over Resolver: Scans MODEL_ROUTES (new entry added by this PR)
Resolver-->>Proxy: Some(ModelRoute { upstream: "claude-haiku-4-5-20251001" })
Proxy->>Anthropic: Forward request with upstream model
Anthropic-->>Proxy: Response + usage tokens
Proxy->>Cost: model_cost("claude-haiku-4-5-20251001")
note over Cost: $0.80/$4.00/$0.08/$1.00 per MTok
Cost-->>Proxy: ModelCost
Proxy-->>App: OpenAI-format response
|
|
Updated the PR in response to Greptile's concerns Changes
|
Add
claude-haiku-4-5-20251001support to desktop Rust backendThe Swift desktop app sends
claude-haiku-4-5-20251001to/v2/chat/completions, but the model was absent fromMODEL_ROUTES, causingresolve_model()to returnNoneand the proxy to reject every request with a400 Bad Request. The backend log shows:Changes
desktop/Backend-Rust/src/models/chat_completions.rs- addedomi-haikuandclaude-haiku-4-5-20251001entries toMODEL_ROUTESdesktop/Backend-Rust/src/routes/chat_completions.rs- added Haiku pricing tomodel_cost(), added a dedicatedtest_resolve_model_haikutest (matching the pattern oftest_resolve_model_sonnetandtest_resolve_model_opus), and removedomi-haikufromtest_resolve_model_unknownwhere it didn't belongNote on the test changes
test_resolve_model_unknownpreviously includedassert!(resolve_model("omi-haiku").is_none()). Rather than flipping that assertion tois_some()(which would be semantically wrong in a test calledunknown), I removed it from that test entirely and added a proper dedicated test with fullpublic_model,upstream_model, andproviderassertions. My read is theomi-haikuline was added there simply because Haiku wasn't implemented yet, if it was deliberately excluded, I'd be happy to revert.