Skip to content

fix(agent): stabilize dynamic tool contracts - #349

Merged
fcoury merged 1 commit into
mainfrom
fcoury/agent-tool-contract
Aug 27, 2026
Merged

fcoury merged 1 commit into
mainfrom
fcoury/agent-tool-contract

Conversation

@fcoury

@fcoury fcoury commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

A fresh read_file request that started after line 1 was treated as a continuation and rejected unless it supplied a prior editor revision. That made targeted reads such as line 210 fail even though no snapshot continuation was involved. Tool failures were also split between transport status, JSON payloads, and generic activity copy, leaving both the model and user with inconsistent recovery signals.

This change makes the Agent tool boundary consistent:

  • allows fresh reads from any valid one-based line while preserving optional revision checks for snapshot-consistent continuations;
  • returns bounded structured errors with stable codes, retryability, and recovery guidance, and propagates semantic ok: false results as transport failures;
  • adds schema defaults for common editor and diagnostics calls;
  • gives language-server actions and failures concise activity labels;
  • versions persisted tool contracts so incompatible saved threads keep their transcript but start a compatible session on the next message.

How to Test

  1. Open Red on src/main.rs, open :Agent, and ask it to call read_file with start_line: 210, line_count: 3, and no expected_revision.
    • Expected: the read completes and the answer is grounded in lines 210-212.
  2. Ask the Agent to read /tmp/x.txt, then expand the activity disclosure.
    • Expected: the row says Reading x.txt — outside workspace, and the tool result includes outside_workspace with allowed-path recovery guidance.
  3. Run cargo test --all-targets --all-features -- --skip dot_repeats_linewise_paste_and_visual_block_insert.
  4. Run cargo clippy --all-targets --all-features -- -D warnings.

The skipped editing stress test currently stack-overflows on the unchanged base branch as well; the exact failure was reproduced before publishing this PR.

@fcoury
fcoury merged commit 3eb36ad into main Aug 27, 2026
13 checks passed
@fcoury
fcoury deleted the fcoury/agent-tool-contract branch August 27, 2026 14:57
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