Skip to main content

Module sanitize

Module sanitize 

Source
Expand description

Tool-id โ†” sanitized-name mapping for LLM and MCP surfaces.

LLM APIs (OpenAI function-calling, Anthropic tools, MCP) require identifiers to match [a-zA-Z0-9_-]. ATD tool ids use : and . for namespace/domain/action structure. This module translates in both directions.

Note that sanitization is lossy โ€” a:b and a.b both map to a_b. Reverse lookup therefore requires the caller to provide the set of known original ids.

Functionsยง

desanitize_tool_name
Map a sanitized name back to the original tool id by searching the provided known-id set. Returns None if no match.
detect_collisions
Check whether sanitization would cause a collision within the given set of ids. Useful for detecting adapter-shape problems before they surface as confusing LLM behavior.
sanitize_tool_name
Map an ATD tool id to an LLM-/MCP-safe name.