Skip to content

feat(tools): ClaimSource provenance, ErrorDomain recovery, MCP tool pruning#2293

Merged
bug-ops merged 3 commits intomainfrom
research-tools-memtool-dynamic
Mar 27, 2026
Merged

feat(tools): ClaimSource provenance, ErrorDomain recovery, MCP tool pruning#2293
bug-ops merged 3 commits intomainfrom
research-tools-memtool-dynamic

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

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

Summary

Implements three tool-reliability improvements from research issues:

  • ClaimSource (#2266): Enum on ToolOutput tracking executor provenance (Shell, FileSystem, WebScrape, Mcp, A2a, CodeSearch, Diagnostics, Memory). Added as Option<ClaimSource> to avoid struct-update blast radius. Set by all executors; exposed in AuditEntry for structured audit logs.

  • ErrorDomain (#2253): 4-domain companion to ToolErrorCategory mapping all 11 error categories to Planning/Reflection/Action/System recovery strategies. Exposes domain() method and is_auto_retryable() / needs_llm_correction() predicates for agent loop dispatch.

  • ToolPruning (#2204): ToolPruningConfig in McpConfig + prune_tools<P: LlmProvider>() free function implementing MemTool workflow-mode pruning (LLM removes irrelevant MCP tools, always_include bypasses, max_tools cap). Not yet wired into agent loop — wiring is a follow-up PR.

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace -- -D warnings — zero warnings
  • cargo nextest run --workspace --lib --bins — 6305 passed, 0 failed
  • ErrorDomain: all 11 category→domain mappings tested, all helper methods tested
  • ClaimSource: serde roundtrip tested, executor assignment tested
  • ToolPruning: parse_name_array handles markdown fences, empty array, unknown names

Known limitations (tracked as follow-up issues)

  • prune_tools not wired into agent loop — wiring PR must first resolve:
    • max_tools == 0 semantics bug (should mean "no cap", currently "no candidates")
    • always_include cap semantics (do pinned tools count toward max_tools?)
    • MCP tool description sanitization before interpolation into pruning prompt (prompt injection risk)
    • Per-message caching to avoid redundant LLM calls in multi-turn conversations
  • ClaimSourceContentSourceKind bridge in zeph-sanitizer is a follow-up (requires zeph-core integration)

Closes

Closes #2204
Closes #2253
Closes #2266

@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate config Configuration file changes enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 27, 2026
…runing

Implements three tool-reliability improvements from research issues:

- ClaimSource enum on ToolOutput tracks executor provenance (Shell, FileSystem,
  WebScrape, Mcp, A2a, CodeSearch, Diagnostics, Memory). Added as
  Option<ClaimSource> to avoid construction-site blast radius. Set by all
  existing executors; exposed in AuditEntry for structured audit logs. (#2266)

- ErrorDomain 4-domain companion to ToolErrorCategory maps all 11 categories
  to Planning/Reflection/Action/System recovery strategies. Exposes domain()
  method and helper predicates is_auto_retryable() and needs_llm_correction()
  for agent loop recovery dispatch. AuditEntry gains error_domain field. (#2253)

- ToolPruningConfig added to McpConfig with enabled/max_tools/pruning_provider/
  min_tools_to_prune/always_include fields. prune_tools<P: LlmProvider>() free
  function implements workflow-mode pruning (remove irrelevant tools via LLM,
  merge with always_include, cap at max_tools). Not yet wired into agent loop;
  wiring is a follow-up PR after max_tools semantics and description sanitization
  are resolved. (#2204)

Closes #2204
Closes #2253
Closes #2266
@bug-ops bug-ops force-pushed the research-tools-memtool-dynamic branch from 953bf02 to 7855ad9 Compare March 27, 2026 23:02
@bug-ops bug-ops enabled auto-merge (squash) March 27, 2026 23:04
@bug-ops
Copy link
Copy Markdown
Owner Author

bug-ops commented Mar 27, 2026

CI is failing with 6 error[E0063]: missing field claim_sourcein initializer ofzeph_tools::ToolOutput`` errors in tests/integration.rs at lines 177, 195, 213, 247, 286, 2354. The PR adds `claim_source: Option` to `ToolOutput` but did not update `ToolOutput { ... }` struct literals in the integration test file. Fix: add `claim_source: None,` to each of those initializers.

@github-actions github-actions bot added the tests Test-related changes label Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/XL Extra large PR (500+ lines) tests Test-related changes

Projects

None yet

1 participant