Quickly create a new Atomic Agents tool with proper input/output schemas and error handling
Creates a new Atomic Agents tool with proper input/output schemas, error handling, and configuration. Use this when you need to quickly scaffold a tool for API calls, file operations, or external services that follows Atomic Agents patterns.
/plugin marketplace add BrainBlend-AI/atomic-agents/plugin install atomic-agents@brainblend-pluginsDescription of the tool to create (e.g., "a weather API tool that fetches current conditions")Create a new Atomic Agents tool based on the user's description.
If $ARGUMENTS is provided, parse the tool description. Otherwise, ask:
Use the Skill tool to load: atomic-tools
Use the Skill tool to load: atomic-schemas
tools/ directory or determine where to create the toolUse the schema-designer agent for the schemas:
Task(subagent_type="schema-designer", prompt="Design input and output schemas for a tool that: [description]. Include error handling schema if applicable. Use ultrathink.")
[tool_name]_tool.py:
from atomic_agents.lib.base.base_tool import BaseTool, BaseToolConfig
from atomic_agents.lib.base.base_io_schema import BaseIOSchema
from pydantic import Field
from typing import Optional
import os
# ============================================================
# Input/Output Schemas
# ============================================================
class [Tool]InputSchema(BaseIOSchema):
"""Input for [tool purpose]."""
param: str = Field(
...,
description="Description of this parameter"
)
class [Tool]OutputSchema(BaseIOSchema):
"""Successful output from [tool purpose]."""
result: str = Field(
...,
description="The result from the tool"
)
class [Tool]ErrorSchema(BaseIOSchema):
"""Error output from [tool purpose]."""
error: str = Field(
...,
description="Error message describing what went wrong"
)
error_code: Optional[str] = Field(
default=None,
description="Error code if available"
)
# ============================================================
# Tool Configuration
# ============================================================
class [Tool]Config(BaseToolConfig):
"""Configuration for [Tool]."""
api_key: str = Field(
default_factory=lambda: os.getenv("[SERVICE]_API_KEY", ""),
description="API key for [service]"
)
base_url: str = Field(
default="https://api.example.com",
description="Base URL for API requests"
)
timeout: int = Field(
default=30,
description="Request timeout in seconds"
)
# ============================================================
# Tool Implementation
# ============================================================
class [Tool](BaseTool):
"""
Tool for [purpose].
This tool [detailed description of what it does].
"""
input_schema = [Tool]InputSchema
output_schema = [Tool]OutputSchema
def __init__(self, config: [Tool]Config = None):
"""Initialize the tool with configuration."""
super().__init__(config or [Tool]Config())
self.config: [Tool]Config = self.config
def run(self, params: [Tool]InputSchema) -> [Tool]OutputSchema | [Tool]ErrorSchema:
"""
Execute the tool.
Args:
params: Input parameters for the tool
Returns:
[Tool]OutputSchema on success, [Tool]ErrorSchema on failure
"""
try:
# Validate configuration
if not self.config.api_key:
return [Tool]ErrorSchema(
error="API key not configured",
error_code="CONFIG_ERROR"
)
# Implement tool logic here
# Example:
# response = requests.get(
# f"{self.config.base_url}/endpoint",
# params={"q": params.param},
# headers={"Authorization": f"Bearer {self.config.api_key}"},
# timeout=self.config.timeout
# )
# response.raise_for_status()
# data = response.json()
result = f"Processed: {params.param}" # Replace with actual logic
return [Tool]OutputSchema(result=result)
except Exception as e:
return [Tool]ErrorSchema(
error=str(e),
error_code="EXECUTION_ERROR"
)
# ============================================================
# Convenience Instance
# ============================================================
# Default tool instance (can be overridden with custom config)
tool = [Tool]()
Direct Usage:
from [module].[tool_name]_tool import tool, [Tool]InputSchema
# Run the tool
input_data = [Tool]InputSchema(param="value")
result = tool.run(input_data)
if isinstance(result, [Tool]ErrorSchema):
print(f"Error: {result.error}")
else:
print(f"Result: {result.result}")
With Custom Config:
from [module].[tool_name]_tool import [Tool], [Tool]Config, [Tool]InputSchema
# Custom configuration
config = [Tool]Config(
api_key="your-api-key",
timeout=60
)
# Create tool with custom config
custom_tool = [Tool](config=config)
result = custom_tool.run([Tool]InputSchema(param="value"))
With Agent:
from atomic_agents.agents.base_agent import AtomicAgent, AgentConfig
from [module].[tool_name]_tool import tool
# Agent can use the tool
# (Show how to integrate with agent's tool orchestration)
Perform a quick validation:
Report any issues found.
Provide: