Registers a new agent tool via ToolRegistry with OpenTelemetry tracing. Use when creating a new tool function, adding a tool to an agent, or extending the tool surface.
Step-by-step workflow for creating and registering a new agent tool in the template.
Write the tool function in py/apps/app-template/tools/:
tools/my_tools.py).str (typically json.dumps(result)).tools/sample_tools.py:
def summarize_text(text: str) -> str:
"""Summarize input text, returning JSON with summary and word count."""
words = text.split()
summary = " ".join(words[:min(len(words), 24)])
return json.dumps({"summary": summary, "word_count": len(words)})
Register with ToolRegistry:
@registry.register:
from foundrykit import ToolRegistry
registry = ToolRegistry()
@registry.register
def my_tool(query: str) -> str:
...
Add to agent spec (if using YAML-driven agents):
tools: list.Build toolset for agent:
registry.build_toolset() to get a ToolSet compatible with Azure Agents SDK.AgentManager.temporary_agent(tool_resources=...).Test the tool:
@registry.register and return str.httpx with explicit timeout. Handle errors gracefully — return error JSON, don't raise.str (JSON-serialized)@registry.registertools: list