Skip to content

fix(mcp): prune_tools max_tools==0 no-cap, description sanitization, always_include semantics#2316

Merged
bug-ops merged 1 commit intomainfrom
fix/2294-prune-tools-max-tools
Mar 28, 2026
Merged

fix(mcp): prune_tools max_tools==0 no-cap, description sanitization, always_include semantics#2316
bug-ops merged 1 commit intomainfrom
fix/2294-prune-tools-max-tools

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 28, 2026

Summary

All three fixes are prerequisites before prune_tools is wired into the agent loop.

Changes

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --features full --workspace -- -D warnings — no new warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 6913/6913 passed
  • New unit tests: max_tools_zero_means_no_cap, description_sanitization_strips_control_chars_and_caps, always_include_bypasses_max_tools_cap
  • Security audit: char::is_control() covers all C0/C1 controls including \n, \r, \t, null byte; whitelist on LLM-returned names remains intact

Closes #2294, Closes #2297, Closes #2296

…always_include semantics

- max_tools==0 now means no cap on LLM-selected candidates (#2294)
- sanitize tool names/descriptions before prompt interpolation to prevent
  prompt injection from attacker-controlled MCP servers (#2297)
- document that always_include tools bypass max_tools cap; cap applies
  only to LLM-selected candidates (#2296)

Add three unit tests: max_tools_zero_means_no_cap,
description_sanitization_strips_control_chars_and_caps,
always_include_bypasses_max_tools_cap.

Closes #2294, Closes #2297, Closes #2296
@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 28, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 28, 2026 07:44
@bug-ops bug-ops merged commit 7267bfa into main Mar 28, 2026
25 checks passed
@bug-ops bug-ops deleted the fix/2294-prune-tools-max-tools branch March 28, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

1 participant