Skip to content

fix(tool-binding): tell a missing binding from an unknown tool - #2081

Closed
zerob13 wants to merge 1 commit into
mainfrom
zerob13/2028-tool-errors
Closed

zerob13 wants to merge 1 commit into
mainfrom
zerob13/2028-tool-errors

Conversation

@zerob13

@zerob13 zerob13 commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Refs #2028 · Refs #2015

Summary

ToolBinding::handler/definitions/transfer used to return Result<_, String>. ToolExecutor's admit() wrapped the text as-is into HostError::failed, so the internal text request <id> has no active tool binding could end up in the model context. This PR splits the error by kind:

  • BindingError { NoActiveBinding, UnknownTool }, with the same Display text as before.
  • ToolExecutor maps by kind: UnknownTool keeps Unknown tool: <name>, which the model can act on. NoActiveBinding is a runtime defect: it is logged with its id via tracing::error!, and the model sees only Tool was not executed: its request has no tool binding, matching the existing "not executed" texts.
  • A failed transfer during Loop budget recovery is reported as AgentError::fault("Loop", …), the Loop's own inconsistency, instead of InvalidInput.
  • The NestedToolHost signature is unchanged; dim-codemode is untouched.
  • The error column for handler/transfer in tool-contributions §7 is updated to match.

Correction to #2028: the leak cannot be reproduced through public flows. The new flow test a_call_whose_binding_reloaded_settles_as_a_reload_without_internal_text restarts ToolBinding while the model is still streaming. Both before and after this change, the model sees Tool was not executed: capability reloading: Loop and ToolExecutor reload together with ToolBinding, so an undispatched call never reaches admit(). Unknown tool is also unreachable from the main flow, because ModelProvider already rejects undeclared tools at the stream boundary (output.rs:669); only Code Mode child calls take that path. So the value of this PR is separating defects from errors the model can correct, not fixing a bug users can observe. The test pins that behavior. It passes before and after the change; it is not a regression test.

Not changed (proposed kinds are listed in the #2015 comment): the String errors of bind/bind_current/prepare/open.

Design rule checklist

  • Scope: n/a, no new part.
  • Commands and results: n/a, no event change.
  • Handover: n/a.
  • Timeline before callbacks: n/a.
  • Infrastructure: unchanged.
  • Core mechanisms and consumers gain no plugin-specific handling.
  • Batch: n/a.
  • Context: model-visible text no longer includes internal ids; unchanged otherwise.
  • No reading another plugin's internal state or deciding for it.
  • Cross-language faces: no face changes; toolBinding stays internal(hot-path) (see 插件与服务治理:所有者提供操作,逐个扫描所有者 #2015).
  • Business configuration: n/a.
  • Missing mechanism capabilities: none.
  • Timeline: n/a.

Documentation

  • No accepted ADR is modified or deleted.
  • No other module's design is changed; only ToolBinding's own error column.
  • No delivery status added.

Verification

  • cargo test -p dim-agent-capabilities -p dim-codemode --locked: 645 passed / 4 ignored, 70, 16, 9 passed
  • cargo clippy -p dim-agent-capabilities -p dim-codemode --all-targets --locked -- -D warnings: passed
  • cargo fmt --all -- --check, cargo run --locked -p xtask-check: passed

ToolBinding's handler, definitions and transfer returned a String, so
ToolExecutor wrote the internal 'request <id> has no active tool binding'
text into the tool result the model reads. They now return BindingError:
UnknownTool keeps its model-facing text, NoActiveBinding is a runtime
defect that is logged with its request id while the model reads only
that the call did not run, and Loop reports a failed transfer as its own
fault instead of invalid input.

A flow test pins that a binding reload during a request settles the call
as a reload without internal text.

Refs #2028
@zerob13

zerob13 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Closing in favor of the #2028 target contract (#2100): its deletion list removes ToolBinding::handler, definitions and the old transfer signature that this PR changes, and the ToolBinding error kinds are to be designed together with its data face. The flow test a_call_whose_binding_reloaded_settles_as_a_reload_without_internal_text and the finding that the leak is unreachable through public flows remain input to #2028 (see the scan report, item 8). The commit stays reachable from this PR.

@zerob13 zerob13 closed this Nov 23, 2026
@zerob13
zerob13 deleted the zerob13/2028-tool-errors branch November 23, 2026 08:26
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.

1 participant