Drop capability reader tools duplicated by `FileSystem`

Merged
DO
1mo ago
+769-99

Closes #9398

Built on #10673 (ToolDefinition.unless_tool_kind, RunContext.tool_name_for_kind) and #10674 (FileSystem tool kinds), both merged.

What

Three capabilities offer their own reader for files they keep in the workspace. When those files are in the run's workspace and FileSystem is on the agent, read_file reads them too, so the model had two tools for one job. Each reader now steps aside for FileSystem's read_file by tool kind:

CapabilityReaderSteps aside whenKeeps its reader with
ToolOutputLimitsread_tool_resultthe store is the default WorkspaceStore() (no workspace= of its own)WorkspaceStore(workspace=...), LocalFileStore, any other OverflowStore
Memoryread_memorythe store resolved for the run (after store_resolver) is a FileStore with no workspace= and a relative directory inside the working directoryInMemoryStore, SqliteMemoryStore, PostgresMemoryStore, a FileStore with its own workspace=
RepoContextinventory tool (expose_inventory_tool=True)every asset root is inside the working directory (the default roots are)asset roots outside the working directory

How

  • By kind, decided from configuration. Each reader is marked unless_tool_kind=READ_FILE_KIND (through the tool's prepare), so core leaves it out of every run step that has a tool of FileSystem's read kind, whatever it is named or prefixed as. The decision makes no workspace calls and doesn't change within a run, so the prompt stays cacheable. Deferred tools count as present, per core.
  • Instructions stay static. Memory's guidance and RepoContext's instructions name no reader, so they are the same with or without FileSystem and stay in the cached prefix. Memory's per-request <memory> block says where the scope's files are when read_file reads them. The spill marker and Memory's notices (lines left out of the injected notebook, an old_text that was not found) are per call, so they use ctx.tool_name_for_kind(READ_FILE_KIND) for the reader's actual name and give the file's path. When it returns None, they name the capability's own reader.
  • No name checks, no re-spilling. read_tool_result gets its own kind, READ_TOOL_RESULT_KIND (exported). ToolOutputLimits exempts from reduction a call whose tool has that kind, and a READ_FILE_KIND call whose path resolves under .pydantic-ai-harness/tool-output/. This replaces the call.tool_name == READ_TOOL_NAME check, so a prefixed read_tool_result is exempt too. An ordinary read_file is told apart by its path without a workspace call.
  • No binary-spill exception. read_file returns images and PDFs as files and previews other binaries (#9596).

The earlier ProvidesFileTools / FileToolsInfo / FileSystem.can_read / can_read_tree approach is reverted in full (first commit), along with its per-request workspace I/O, per-spill requires_reader metadata, longest-line heuristic and FILE_READ_OVERHEAD_CHARS.

Trade-offs and gaps (documented)

  • read_tool_result's from_end has no read_file equivalent. Filtering by pattern maps to search_files / grep.
  • The decision comes from the capability's store, not from FileSystem's access rules. denied_patterns that cover the files (or allowed_patterns that leave them out) still drop the dedicated reader while read_file refuses the files. The workaround is a store with a workspace= of its own.
  • Memory's file path includes the namespace. With file tools over the run's workspace, the model could already read every namespace's files. The docs now say to give the store its own workspace= when namespaces separate users.

Telemetry

Nothing new is emitted. Leaving a tool out happens in core's tool resolution, and the reads go through core's tool spans and FileSystem's events.

Docs

The README and docs/harness/*.md page for ToolOutputLimits, Memory, RepoContext and FileSystem (a new "Capabilities that step aside for read_file" section), plus the harness skill references.

Tests

Through Agent with FunctionModel:

  • The reader is dropped with FileSystem, including under PrefixTools, and the marker and guidance name the prefixed tool (repo_read_file).
  • The reader is kept without FileSystem, and with WorkspaceStore(workspace=...), LocalFileStore, InMemoryStore, a FileStore with its own workspace, or one outside the working directory.
  • A spill read back through read_file is not spilled again, though it is over the band's threshold, while other read_file calls are still reduced.
  • A prefixed read_tool_result is named in the marker and exempt by kind, while the bare name alone no longer exempts a tool.
  • Memory with store_resolver, and the dropped-lines notice naming read_file(path=...).

šŸ¤– Generated with Claude Code