Skip to content

feat(stage-router): Extend retrieval cmd identification - #906

Open
grahamking wants to merge 2 commits into
mainfrom
gk-stage-in-src
Open

grahamking wants to merge 2 commits into
mainfrom
gk-stage-in-src

Conversation

@grahamking

@grahamking grahamking commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
  • Stricter shell parsing to identify file reads.

We identify an error by looking for strings such MemoryError in tool
output. If that string appears in a log file we read for example, then
it should not count.

Previously we skipped it correctly if the output was Claude and Pi "Read" tools,
but Codex does everything with bash which we did not skip.

Now we parse that and categorize if it is a read.

On the DeepSWE runs I checked, this reduces capable model use from 19% of
requests to 15%. The classification takes ~265 ns.

  • Missing file reads are not failures but normal exploration.

They occur at the same rate (~38%) in successful and failed tasks.

Applies to both Codex and Claude.

  • Empty text blocks occupy no slots.

We look at the last three tool calls. Previously a tool with no output
(e.g. mkdir) didn't occupy one of those three slots, but two together
did because we join on \n. That caused errors to age out even though
we don't have any new evidence. Now empty blocks are skipped.

The shell parsing was built by extracting commands from three DeepSWE
runs (one Luna, two Sol). It was prototyped in Python before porting
to Rust. Both Astra xhigh and Opus 5.5 xhigh worked on it. I think it is
remarkably readable for what it is.

There are more tests than usual because of this.

Assisted-by: Pi:GPT 6 Astra xhigh
Assisted-by: Claude:Opus 5.5 xhigh
Signed-off-by: Graham King grahamk@nvidia.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of results from file-reading tools and safe shell inspection commands, reducing the chance that inspection output is misclassified as an error or test result.
    • Retrieval results containing text continue to count toward the results window.
    • Explicitly failed retrievals remain visible as signals, except when the message indicates a missing file.

- Stricter shell parsing to identify file reads.

We identify an error by looking for strings such `MemoryError` in tool
output. If that string appears in a log file we read for example, then
it should not count.

Previously we skipped it correctly if the output was Claude and Pi "Read" tools,
but Codex does everything with bash which we did not skip.

Now we parse that and categorize if it is a read.

On the DeepSWE runs I checked, this reduces capable model use from 19% of
requests to 15%. The classification takes ~265 ns.

- Missing file reads are not failures but normal exploration.

They occur at the same rate (~38%) in successful and failed tasks.

Applies to both Codex and Claude.

- Empty text blocks occupy no slots.

We look at the last three tool calls. Previously a tool with no output
(e.g. `mkdir`) didn't occupy one of those three slots, but two together
did because we join on `\n`. That caused errors to age out even though
we don't have any new evidence. Now empty blocks are skipped.

The shell parsing was built by extracting commands from three DeepSWE
runs (one Luna, two Sol). It was prototyped in Python before porting
to Rust. Both Astra xhigh and Opus 5.5 xhigh worked on it. I think it is
remarkably readable for what it is.

There are more tests than usual because of this.

Assisted-by: Pi:GPT 6 Astra xhigh
Assisted-by: Claude:Opus 5.5 xhigh
Signed-off-by: Graham King <grahamk@nvidia.com>
@grahamking
grahamking requested a review from a team as a code owner October 2, 2026 19:04
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

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

Built to branch gh-pages at 2026-10-02 19:57 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@coderabbitai

coderabbitai Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA-NeMo/Switchyard/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 526666fd-a3d4-4f8d-92b8-a798a1de8831

📥 Commits

Reviewing files that changed from the base of the PR and between 4177133 and 4fd82fb.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (2)
  • crates/libsy/Cargo.toml
  • crates/libsy/src/algorithms/util/tool_signals.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

Tool-result extraction now recognizes built-in read tools, editor view calls, and bounded shell inspection commands. Retrieval results follow updated error-scanning rules, including an exemption for recognized missing-file messages.

Changes

Tool retrieval signal handling

Layer / File(s) Summary
Recognize retrieval calls and parse shell commands
crates/libsy/Cargo.toml, crates/libsy/src/algorithms/util/tool_signals.rs
Tool-call arguments retain raw command values for retrieval detection. Bounded shell parsing recognizes supported inspection commands and rejects unsafe or unrecognized segments. Tests cover mixed commands, nested shell inspection, and parsing limits.
Handle retrieval result signals
crates/libsy/src/algorithms/util/tool_signals.rs
Successful retrieval results and retrieval failures with recognized missing-file messages are exempt from error-text scanning. Tests cover other failed reads and result-window behavior.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 4fd82

This change refines how tool-error signals are detected for file-read commands. It only affects heuristic routing signals. No concrete defects were identified, so the change appears ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 1 files. (1 skipped: … 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 describes the main change: extending retrieval command identification. It matches the shell parsing and retrieval detection work in the changeset.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


A rabbit checks commands with care,
It sniffs out reads from shell-word pairs.
A missing path gets noted right,
While other errors stay in sight.
It hops along, its tests all green.

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

@sabhatinas

Copy link
Copy Markdown
Contributor

Great contribution!

  1. When file reads are missing, should we categorize them into the Observation bucket?
  2. As discussed, it would be great if we can benchmark algo changes on a subset of TB 2.1 and DeepSWE tasks.

Thanks Tina!

Signed-off-by: Graham King <grahamk@nvidia.com>
@grahamking

Copy link
Copy Markdown
Contributor Author

When file reads are missing, should we categorize them into the Observation bucket?

Done!

@grahamking
grahamking enabled auto-merge (squash) October 2, 2026 21:31

This branch has not been deployed

No deployments
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.

2 participants