Drop capability reader tools duplicated by `FileSystem`
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:
| Capability | Reader | Steps aside when | Keeps its reader with |
|---|---|---|---|
ToolOutputLimits | read_tool_result | the store is the default WorkspaceStore() (no workspace= of its own) | WorkspaceStore(workspace=...), LocalFileStore, any other OverflowStore |
Memory | read_memory | the store resolved for the run (after store_resolver) is a FileStore with no workspace= and a relative directory inside the working directory | InMemoryStore, SqliteMemoryStore, PostgresMemoryStore, a FileStore with its own workspace= |
RepoContext | inventory 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'sprepare), so core leaves it out of every run step that has a tool ofFileSystem'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 andRepoContext's instructions name no reader, so they are the same with or withoutFileSystemand stay in the cached prefix.Memory's per-request<memory>block says where the scope's files are whenread_filereads them. The spill marker andMemory's notices (lines left out of the injected notebook, anold_textthat was not found) are per call, so they usectx.tool_name_for_kind(READ_FILE_KIND)for the reader's actual name and give the file's path. When it returnsNone, they name the capability's own reader. - No name checks, no re-spilling.
read_tool_resultgets its own kind,READ_TOOL_RESULT_KIND(exported).ToolOutputLimitsexempts from reduction a call whose tool has that kind, and aREAD_FILE_KINDcall whosepathresolves under.pydantic-ai-harness/tool-output/. This replaces thecall.tool_name == READ_TOOL_NAMEcheck, so a prefixedread_tool_resultis exempt too. An ordinaryread_fileis told apart by its path without a workspace call. - No binary-spill exception.
read_filereturns 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'sfrom_endhas noread_fileequivalent. Filtering bypatternmaps tosearch_files/grep.- The decision comes from the capability's store, not from
FileSystem's access rules.denied_patternsthat cover the files (orallowed_patternsthat leave them out) still drop the dedicated reader whileread_filerefuses the files. The workaround is a store with aworkspace=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 ownworkspace=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 underPrefixTools, and the marker and guidance name the prefixed tool (repo_read_file). - The reader is kept without
FileSystem, and withWorkspaceStore(workspace=...),LocalFileStore,InMemoryStore, aFileStorewith its own workspace, or one outside the working directory. - A spill read back through
read_fileis not spilled again, though it is over the band's threshold, while otherread_filecalls are still reduced. - A prefixed
read_tool_resultis named in the marker and exempt by kind, while the bare name alone no longer exempts a tool. Memorywithstore_resolver, and the dropped-lines notice namingread_file(path=...).
š¤ Generated with Claude Code