Skip to content

fix: Stamp the selected ModelId on LlmRequest much earlier - #393

Draft
grahamking wants to merge 1 commit into
mainfrom
gk-early-stamp
Draft

fix: Stamp the selected ModelId on LlmRequest much earlier#393
grahamking wants to merge 1 commit into
mainfrom
gk-early-stamp

Conversation

@grahamking

@grahamking grahamking commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Previously libsy would give CallModel a request with the wrong model
ID, and a Decision with the correct (chosen by routing algo) model ID.
libsy-llm-client would stamp the later onto the former before making
the actual call.

Now Driver::call_model stamps the correct model ID onto LlmRequest,
so everything after that can use LlmRequest directly.

This was confusing me for a while. Seems easier to understand like this.

This also means CallModel can read the selected_model_id() off the
request now, which gives us options for changing Decision later.

Claude's review:

The net effect is simpler client code and a cleaner contract on CallModel.

Assisted-by: Codex:GPT 5.6 Sol high
Signed-off-by: Graham King grahamk@nvidia.com

Summary by CodeRabbit

  • Improvements

    • Requests now consistently use the model selected by routing.
    • Random-routing behavior now preserves the selected model in outgoing client requests.
    • Model selection and request handling are more consistent across token counting, rewrites, and standard calls.
  • Documentation

    • Clarified how selected models are represented and propagated through requests and routed clients.

Previously `libsy` would give `CallModel` a request with the wrong model
ID, and a `Decision` with the correct (chosen by routing algo) model ID.
`libsy-llm-client` would stamp the later onto the former before making
the actual call.

Now `Driver::call_model` stamps the correct model ID onto `LlmRequest`,
so everything after that can use `LlmRequest` directly.

This was confusing me for a while. Seems easier to understand like this.

This also means `CallModel` can read the `selected_model_id()` off the
request now, which gives us options for changing `Decision` later.

Assisted-by: Codex:GPT 5.6 Sol high
Signed-off-by: Graham King <grahamk@nvidia.com>
@grahamking

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1

🚀 View preview at
https://NVIDIA-NeMo.github.io/Switchyard/pr-preview/pr-393/

Built to branch gh-pages at 2026-08-12 22:36 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fe914580-0321-44af-b938-58e6562f8186

📥 Commits

Reviewing files that changed from the base of the PR and between 0151621 and aa06e52.

📒 Files selected for processing (7)
  • crates/libsy-llm-client/src/client.rs
  • crates/libsy-llm-client/src/run.rs
  • crates/libsy/src/core/algorithm.rs
  • crates/protocol/src/client.rs
  • crates/protocol/src/envelope.rs
  • crates/protocol/src/llm.rs
  • tests/test_libsy_minimal_bindings.py

Walkthrough

Routing now stamps the selected model into requests. LLM clients, tracing, error handling, tests, and documentation use the request model as the routed target.

Changes

Request-Model Routing

Layer / File(s) Summary
Stamp the selected model
crates/libsy/src/core/algorithm.rs
Driver::call_model writes the selected model into request.llm_request.model. CallModel::selected_model_id() exposes the stamped value. Related tests verify the request and accessor.
Dispatch the request model
crates/libsy-llm-client/src/client.rs, crates/protocol/src/*.rs
Client entry points resolve models into request payloads. RoutedLlmClient::call forwards the request model without overriding it. Protocol documentation describes the updated model contract.
Use the selected model in observations
crates/libsy-llm-client/src/run.rs, tests/test_libsy_minimal_bindings.py
Tracing, errors, and call observations use CallModel::selected_model_id(). The bindings test verifies that the selected model reaches the client request.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to aa06e

The change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Poem

I stamped the model, said the rabbit with cheer,
Then sent it downstream, precise and clear.
The client now follows the request’s bright trail,
While traces and tests confirm the tale.
“Hop!” said the code, “the target is here!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: stamping the selected model ID onto LlmRequest earlier.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

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