symfonic.core.tools.registry¶
registry ¶
ToolRegistry — tool registration, metadata, filtering, freeze.
Per ADR-PFX-009 and TDD §2.6: Registry frozen at compile(), tools filtered by capability, category, safety, and cost.
@symfonic_tool (Roadmap Item 6) is now GA: tools produced by the
decorator carry a _symfonic_metadata attribute, and register
lifts that metadata into the corresponding ToolRegistration fields.
The former experimental_tool_decorator gate has been retired — the
decorator ships stable and no flag is required. set_experimental_tool_decorator
survives as a deprecated no-op for backward compatibility.
SafetyLevel ¶
Bases: str, Enum
Safety classification for tools.
ToolCategory ¶
Bases: str, Enum
Categories for tool classification.
ToolRegistration
dataclass
¶
ToolRegistration(tool: BaseTool, category: ToolCategory = ToolCategory.CUSTOM, safety_level: SafetyLevel = SafetyLevel.RESTRICTED, max_calls_per_invocation: int | None = None, visible_to_agents: bool = True, cost_usd: float | None = None, requires: type | None = None)
Metadata for a registered tool.
ToolRegistry ¶
Tool registration, filtering, cost estimation, and freeze.
Frozen automatically by AgentGraph.compile(). After freeze, register() raises RuntimeError.
Source code in src/symfonic/core/tools/registry.py
all_tools ¶
catalog ¶
Return this registry's :class:ToolCatalog reading (T3.1.2).
The catalogue is the single tool metadata/manifest source: name, summary, visibility, category, safety level, cost, and required capability, derived once from these registrations. Callers that used to re-derive any of those from the tool objects should ask the catalogue instead.
A fresh reading is built per call rather than cached, because the
registry is mutable until freeze() and a stale catalogue is
the exact drift this consolidation removes.
Source code in src/symfonic/core/tools/registry.py
cost_usd_for_invocation ¶
Calculate total cost for a set of tool invocations.
Returns None if any tool has unknown cost.
Source code in src/symfonic/core/tools/registry.py
filter ¶
filter(allowed_names: list[str] | None = None, categories: list[ToolCategory] | None = None, max_safety_level: SafetyLevel = SafetyLevel.DANGEROUS, agent_visible_only: bool = False, available_capabilities: set[type] | None = None, debug: bool = False) -> list[BaseTool]
Filter tools by criteria.
When debug=True, each excluded tool emits a logger.debug() message.
Source code in src/symfonic/core/tools/registry.py
freeze ¶
get_registration ¶
register ¶
Register a single tool with optional metadata. Returns self for chaining.
Raises SymfonicAgentError(code='bad_request') if tool was
produced by @symfonic_tool and the experimental flag is off.
Source code in src/symfonic/core/tools/registry.py
register_many ¶
Register multiple tools with default metadata. Returns self for chaining.
set_experimental_tool_decorator ¶
Deprecated no-op. @symfonic_tool is GA and needs no gate.
Retained so existing engine wiring and adopter code that toggled
the former experimental gate keep working. The enabled value
is ignored — decorator-produced tools always register.
Source code in src/symfonic/core/tools/registry.py
tools_within_budget ¶
Return tools whose cost is within budget.
If include_unknown_cost is True, tools with no cost info are included.