Skip to main content

Module tool_kind

Module tool_kind 

Source
Expand description

Classifies what produced a tool_result so the proxy never lossy-compresses a file/source-code read the model still needs (e.g. mid-refactor).

The request body only carries the tool result plus an id linking it to the originating tool call. We resolve that id → tool name from the assistant’s tool_use / tool_calls / function_call items, then map the name to a ToolResultKind. A content heuristic (looks_like_source_code) is the fallback for unknown/custom tools so a file read through a non-standard tool is still protected.

Enums§

ToolResultKind
What kind of tool produced a tool_result.

Functions§

anthropic_tool_names
Builds a tool_use_id → tool_name map from Anthropic messages.
classify_tool_name
Maps a tool name (from any agent) to a ToolResultKind.
looks_like_source_code
Heuristic fallback: does this text look like source code (vs command output)?
openai_tool_names
Builds a tool_call_id → function_name map from OpenAI Chat Completions messages (assistant tool_calls[]).
responses_tool_names
Builds a call_id → name map from OpenAI Responses input items (type:"function_call").
should_protect
Whether a tool_result with the given resolved kind and content must be preserved intact (never lossy-compressed) by the proxy.