fix(libsy): restate the routing instruction after windowed conversation - #520
fix(libsy): restate the routing instruction after windowed conversation#520gburachas wants to merge 1 commit into
Conversation
Signed-off-by: Giedrius Burachas <gburachas@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. WalkthroughWindowed judge inputs now append a final routing-only user instruction. The default no-window path remains unchanged. Tests verify the final message position and the default message shape. ChangesWindowed routing behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The PR adds a trailing routing instruction only for windowed conversations while preserving the default path; no actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
Addresses the first of the two changes described in #279. The second, capping the payload size, will be a separate pull request.
What
When an
llm_classifierroute setsrecent_turn_window, one sentence is appended as the last message sent to the judge:Nothing changes when
recent_turn_windowis unset.Why
The judge is asked to classify a request and reply with a routing JSON object. Its instructions lead the payload, which works while that payload is one short message.
With a window configured, the instructions are followed by assistant turns and tool output. The judge then sometimes answers the conversation rather than classifying it. That reply does not parse as a verdict, so the route falls back to its default target: the turn is served, and the only sign that routing did not happen is a warning in the log.
Example: a request of "check my account balance", with a window containing a long stack trace from a failed tool call. The verdict describes the stack trace.
Scope
Only the windowed path is affected. With
recent_turn_windowunset,task_messagessends the opening task and the latest user follow-up, with no assistant or tool content between the instruction and the end of the payload.Tests
Two, in
crates/libsy/src/algorithms/llm_class.rs:a_window_restates_the_routing_instruction_lastasserts the instruction is the last message, not merely present. Position is the whole mechanism: moving the same message to the front makes this test fail.the_default_path_is_left_unchangedasserts the unwindowed request shape is untouched.Naming
An earlier draft called this "reinforcement", which reads as reinforcement learning and is unrelated. The constant is
TRAILING_ROUTING_INSTRUCTIONand the issue has been retitled.How tested
cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceuv run ruff check .One file, 66 lines, of which 45 are the two tests.
Note for anyone reading the CodeRabbit panel: the "Docstring Coverage" check measures Python docstrings and this diff is Rust only.
Summary by CodeRabbit
Improvements
Tests