Give `FileSystem` tools registered tool kinds and typed call parts
Merged
DO
1mo ago+593+593+012345678901234567890123456789-9-9-0123456789
Part of #9398. Step 4 of the plan on #9410: FileSystem registers tool kinds for its tools, using the mechanism #9710 added, so other capabilities can recognize them without comparing tool names. #9410 will then mark its reader tools as superseded by READ_FILE_KIND.
- Every tool in
FILE_SYSTEM_TOOL_NAMESdeclares aToolKindin thefile_systemnamespace (the oneFileSystem's capability events already use), named after the tool:file_system.read_file,file_system.write_file,file_system.edit_file,file_system.list_directory,file_system.search_files,file_system.find_files,file_system.create_directory,file_system.file_info,file_system.list_files,file_system.grep. They are set throughadd_function(tool_kind=...), so the kind is on theToolDefinitionwhatever name or prefix the tool ends up with. - Each kind declares its argument shape as a
TypedDict(ReadFileArgs, ...), which_check_tool_kindschecks against the tool's parameters, including thecontent_hashes=Falsevariants withoutexpected_hash. Calls are promoted to typed call parts (ReadFileCallPart, ...). - Only
read_filegets a typed return part,ReadFileReturnPart. Other capabilities look for its result in history (#9410's readers,DeduplicateFileReads). The other tools return text written for the model, and the capability events already carry their outcomes as structured data. The read kind declares nocontentshape: its result isstr | list[str | BinaryContent], andToolKind(content=...)takestype[T], which a union doesn't satisfy (pyright rejects it). SoReadFileReturnPartis unparameterized and itstyped_contentis untyped. - Kinds, args types and part classes are exported from
pydantic_ai_harness.filesystem. The README, docs page and harness skill reference are updated.
Kind ids are stored in histories, so the names need to be settled before merge. I used the tool names for consistency, not short verbs like file_system.read.
Not in this PR: the name-keyed consumers listed in #9410 (ACP presentation and AcpFileSystemToolset's read_file/write_file, DeduplicateFileReads, CLAI speculative mode and tool rendering, RepoContext's traversal names) can move to these kinds in follow-ups.
Checklist
- No breaking changes in accordance with the version policy. Calls to these tools are now
ToolCallPartsubclasses and carry atool_kind.isinstance(part, ToolCallPart)still holds, and histories that lack the kind still load. - Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
- PR title is fit for the release changelog.
š¤ Generated with Claude Code