feat: Introduce ModelId type - #373
Conversation
|
@CodeRabbit review |
|
|
WalkthroughThe change adds the protocol-level ChangesModel identity migration
Estimated code review effort: 4 (Complex) | ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
|
@CodeRabbit review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
crates/libsy-llm-client/tests/observability.rs (1)
432-432: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep the test router typed as
ModelId.
SingleCallAlgo.target_setretainsVec<String>. Line 451 converts the value only when it createsDecision. StoreVec<ModelId>and constructModelIdinalgo. This makes the helper compile against the same routing contract as production algorithms.The PR objective requires
ModelIdacross routing and test code.Also applies to: 451-451, 476-476
🤖 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 `@crates/libsy-llm-client/tests/observability.rs` at line 432, Update the test router helper around SingleCallAlgo so target_set uses Vec<ModelId> instead of Vec<String>. Construct ModelId values when initializing algo, and pass the typed targets directly into Decision without converting them at the call sites, including the other referenced usages.
🤖 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 `@crates/libsy/src/core/algorithm.rs`:
- Around line 473-483: Before call_model_with_fallback, add a block comment
documenting its fallback-loop invariants: which errors are retryable, how failed
targets are excluded, how routing state is updated, when fallback decisions are
published, and that the original error is returned when all attempts fail.
In `@crates/libsy/src/lib.rs`:
- Line 8: Restore the public LlmTarget and LlmTargetSet exports in the libsy
compatibility surface and retain their definitions for at least one release,
marking them deprecated with migration guidance rather than removing them
immediately. Update the core migration path to preserve these types until the
approved deprecation window is complete.
In `@crates/protocol/src/model_id.rs`:
- Line 114: Remove the project-management comment “This is likely excessive. We
can reduce when things settle.” from the ModelId implementation, leaving the
surrounding code unchanged.
In `@crates/switchyard-server/src/config.rs`:
- Around line 153-157: Update build_targets to reject routes whose callable
targets resolve to the same ModelId, returning a configuration error before
constructing the ClientRouter. Preserve valid distinct targets, and add a
regression test covering duplicate model IDs configured with different
llm_client values to ensure the route fails validation rather than overwriting a
client mapping.
---
Nitpick comments:
In `@crates/libsy-llm-client/tests/observability.rs`:
- Line 432: Update the test router helper around SingleCallAlgo so target_set
uses Vec<ModelId> instead of Vec<String>. Construct ModelId values when
initializing algo, and pass the typed targets directly into Decision without
converting them at the call sites, including the other referenced usages.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ef0c9a9d-3763-4741-b444-a170acbe7d09
📒 Files selected for processing (33)
AGENTS.mdcrates/libsy-llm-client/src/client.rscrates/libsy-llm-client/src/observation.rscrates/libsy-llm-client/src/run.rscrates/libsy-llm-client/tests/observability.rscrates/libsy/README.mdcrates/libsy/src/algorithms/fall_through.rscrates/libsy/src/algorithms/llm_class.rscrates/libsy/src/algorithms/passthrough.rscrates/libsy/src/algorithms/rand.rscrates/libsy/src/algorithms/stage.rscrates/libsy/src/algorithms/subagent_affinity_tests.rscrates/libsy/src/algorithms/util/affinity.rscrates/libsy/src/algorithms/util/escalation.rscrates/libsy/src/algorithms/util/llm_judge.rscrates/libsy/src/algorithms/util/prompts.rscrates/libsy/src/algorithms/util/stage.rscrates/libsy/src/algorithms/util/subagent.rscrates/libsy/src/algorithms/util/target_selector.rscrates/libsy/src/core/algorithm.rscrates/libsy/src/core/classifier.rscrates/libsy/src/error.rscrates/libsy/src/lib.rscrates/libsy/src/observability.rscrates/protocol/src/client.rscrates/protocol/src/lib.rscrates/protocol/src/model_id.rscrates/switchyard-py/src/libsy_bindings.rscrates/switchyard-server/src/config.rscrates/switchyard-server/src/lib.rscrates/switchyard-server/src/routing_log.rscrates/switchyard-server/src/stats/accumulator.rscrates/switchyard-server/tests/server.rs
Identify model ID's (e.g. "openai/gpt-oss-120b") with their own type `ModelId`. That makes it clear what we are passing, and prevent accidentally passing the wrong thing. `ModelId` behaves like a string. It can be printed, deref-ed, compared, etc. Previously that was either `String` or `LlmTarget`. This PR removes `LlmTarget` and `LlmTargetSet`, in favor of `ModelId` and `Vec<ModelId>`. To review start with new file `crates/protocol/src/model_id.rs` which contains the type. Assisted-by: Claude:Opus 5 medium Signed-off-by: Graham King <grahamk@nvidia.com>
Signed-off-by: Graham King <grahamk@nvidia.com>
Signed-off-by: Graham King <grahamk@nvidia.com>
0fdc2be to
77bbdca
Compare
|
@grahamking can you take care of server side (or whichever is duplicate) LLMTarget one which we discussed to delete or update. The one that loads from the config ? |
ayushag-nv
left a comment
There was a problem hiding this comment.
Looks good except from one comment related to complexity / lines of code introduced by model_id.rs
This PR also deletes |
Identify model ID's (e.g. "openai/gpt-oss-120b") with their own type
ModelId. That makes it clear what we are passing, and preventaccidentally passing the wrong thing.
ModelIdbehaves like a string. It can be printed, deref-ed, compared, etc.Previously that was either
StringorLlmTarget. This PR removesLlmTargetandLlmTargetSet, in favor ofModelIdandVec<ModelId>.Also rename
resolve_targetandrequire_targetfunction to more clearly communicate now that we have target / model ID distinction.To review start with new file
crates/protocol/src/model_id.rswhichcontains the type.
Assisted-by: Claude:Opus 5 medium
Assisted-by: Codex:GPT 5.6 Sol high
Signed-off-by: Graham King grahamk@nvidia.com
Summary by CodeRabbit
New Features
Documentation