Skip to content

fix(tools): ignore exec node param when no nodes are connected#474

Merged
penso merged 2 commits intomainfrom
grizzled-climb
Mar 24, 2026
Merged

fix(tools): ignore exec node param when no nodes are connected#474
penso merged 2 commits intomainfrom
grizzled-climb

Conversation

@penso
Copy link
Copy Markdown
Collaborator

@penso penso commented Mar 23, 2026

Summary

Fixes #427 — models (especially weaker ones like Qwen3-Coder) hallucinate values for the node parameter on the exec tool even when it's hidden from the schema, causing repeated "node not found" errors before eventually passing null.

  • Filter empty/whitespace-only node strings so "" or " " are treated as absent
  • Guard node routing behind has_connected_nodes() so hallucinated node values silently fall through to local execution when no nodes exist
  • Add 4 tests covering empty, whitespace, bogus node values, and schema hiding

Validation

Completed

  • cargo +nightly-2025-11-30 fmt --all -- --check
  • cargo +nightly-2025-11-30 clippy -p moltis-tools --all-targets -- -D warnings
  • cargo test -p moltis-tools -- exec::tests (35 tests pass)

Remaining

  • ./scripts/local-validate.sh
  • Full cargo test

Manual QA

  1. Run moltis with no remote nodes configured
  2. Use a model that tends to hallucinate the node param (e.g. Qwen3-Coder-Next-FP8)
  3. Ask it to execute a command — should succeed on first attempt without node errors

Models (especially weaker ones like Qwen3-Coder) hallucinate values for
the `node` parameter even when it is hidden from the tool schema,
causing repeated "node not found" errors before eventually passing null.

Two defensive changes:
- Filter empty/whitespace-only node strings so `""` is treated as absent
- Guard node routing behind `has_connected_nodes()` so hallucinated node
  values silently fall through to local execution when no nodes exist

Entire-Checkpoint: c2261f950302
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 23, 2026

Greptile Summary

This PR fixes model hallucination of the node parameter on the exec tool when no remote nodes are connected. It refactors node routing into two clearly separated code paths — model-supplied values vs. admin-configured default_node — with appropriate behavior for each when nodes are unavailable.

Key changes:

  • Empty or whitespace-only node strings are filtered before being considered, so "" or " " no longer try to resolve a node.
  • When no nodes are connected: hallucinated model values are silently dropped (fall through to local execution), while a configured default_node returns a clear error to the admin.
  • 5 new tests cover: empty param, whitespace-only param, bogus non-empty param, schema hiding, and the default_node-disconnected error path — addressing both issues raised in prior review.
  • The previously flagged concern about default_node silently falling through to local execution has been corrected; it now surfaces a descriptive error message.

Confidence Score: 4/5

  • Safe to merge — logic is correct, both prior review concerns are addressed, and the test suite comprehensively covers the new paths.
  • The fix correctly distinguishes model-hallucinated node values from admin-configured defaults, handles both cases with appropriate semantics, and includes tests for all new branches. One minor Clippy lint (collapsible_else_if) in the else block may fail the -D warnings check job if not caught first.
  • crates/tools/src/exec.rs — the nested if inside the final else branch (lines 381–384) may trigger a Clippy warning under -D warnings.

Important Files Changed

Filename Overview
crates/tools/src/exec.rs Node routing logic refactored to distinguish model-hallucinated node params from admin-configured default_node; empty/whitespace node strings filtered; 5 new tests covering all cases including the default_node-disconnected scenario.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[execute called] --> B[Extract model_node from params\nfilter empty/whitespace]
    B --> C{node_provider\npresent?}
    C -- No --> H[node_ref = None]
    C -- Yes --> D{has_connected_nodes?}
    D -- Yes --> E[node_ref = model_node\nOR default_node]
    D -- No --> F{default_node\nconfigured?}
    F -- Yes --> G[Return error:\ndefault node unavailable]
    F -- No --> I{model_node\npresent?}
    I -- Yes --> J[debug log: ignoring\nmodel-supplied node]
    I -- No --> H
    J --> H
    E --> K{node_ref\nresolved?}
    H --> L[Local / sandbox execution]
    K -- resolve_node_id returns Some --> M[Remote node execution]
    K -- resolve_node_id returns None --> N[Return error:\nnode not found]
Loading

Reviews (2): Last reviewed commit: "fix(tools): error on configured default_..." | Re-trigger Greptile

Comment thread crates/tools/src/exec.rs Outdated
Comment thread crates/tools/src/exec.rs
@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented Mar 23, 2026

Merging this PR will not alter performance

✅ 39 untouched benchmarks
⏩ 5 skipped benchmarks1


Comparing grizzled-climb (bcce4f0) with main (919c443)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ilent fallthrough

Address review feedback: distinguish model-hallucinated node values
(silently ignored) from admin-configured default_node (errors clearly
when no nodes are connected). Add test for the default_node case.

Entire-Checkpoint: 8b5b14566dc7
@penso penso merged commit 4e0ae00 into main Mar 24, 2026
47 of 56 checks passed
@penso penso deleted the grizzled-climb branch March 24, 2026 00:06
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.

[Bug]: Agent repeatedly gets confused about nodes when executing commands

1 participant