Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Build AI agents in Python using the Agentica framework. Agents can implement functions, maintain state, use tools, and coordinate with each other.
When to Use
Use this skill when:
Building new Python agents
Adding agentic capabilities to existing code
Integrating MCP tools with agents
Implementing multi-agent orchestration
Debugging agent behavior
Quick Start
Agentic Function (simplest)
from agentica import agentic
@agentic()asyncdefadd(a: int, b: int) -> int:
"""Returns the sum of a and b"""
...
result = await add(1, 2) # Agent computes: 3
# String (default)
result = await agent.call("What is 2+2?")
# Typed output
result: int = await agent.call(int, "What is 2+2?")
result: dict[str, int] = await agent.call(dict[str, int], "Count items")
# Side-effects onlyawait agent.call(None, "Send message to John")
Premise vs System Prompt
# Premise: adds to default system prompt
agent = await spawn(premise="You are a math expert.")
# System: full control (replaces default)
agent = await spawn(system="You are a JSON-only responder.")
Passing Tools (Scope)
from agentica import agentic, spawn
# In decorator@agentic(scope={'web_search': web_search_fn})asyncdefresearcher(query: str) -> str:
"""Research a topic."""
...
# In spawn
agent = await spawn(
premise="Data analyzer",
scope={"analyze": custom_analyzer}
)
# Per-call scope
result = await agent.call(
dict[str, int],
"Analyze the dataset",
dataset=data, # Available as 'dataset'
analyzer=custom_fn # Available as 'analyzer'
)
SDK Integration Pattern
from slack_sdk import WebClient
slack = WebClient(token=SLACK_TOKEN)
# Extract specific methods@agentic(scope={
'list_users': slack.users_list,
'send_message': slack.chat_postMessage
})asyncdefteam_notifier(message: str) -> None:
"""Send team notifications."""
...
Agent Instantiation
spawn() - Async (most cases)
agent = await spawn(premise="Helpful assistant")
Agent() - Sync (for __init__)
from agentica.agent import Agent
classCustomAgent:
def__init__(self):
# Synchronous - use Agent() not spawn()self._brain = Agent(
premise="Specialized assistant",
scope={"tool": some_tool}
)
asyncdefrun(self, task: str) -> str:
returnawaitself._brain(str, task)
Any OpenRouter slug (e.g., google/gemini-2.5-flash)
Persistence (Stateful Agents)
@agentic(persist=True)asyncdefchatbot(message: str) -> str:
"""Remembers conversation history."""
...
await chatbot("My name is Alice")
await chatbot("What's my name?") # Knows: Alice
For spawn() agents, state is automatic across calls to the same instance.
Token Limits
from agentica import spawn, MaxTokens
# Simple limit
agent = await spawn(
premise="Brief responses",
max_tokens=500
)
# Fine-grained control
agent = await spawn(
premise="Controlled output",
max_tokens=MaxTokens(
per_invocation=5000, # Total across all rounds
per_round=1000, # Per inference round
rounds=5# Max inference rounds
)
)
from agentica import spawn
from agentica.logging.loggers import StreamLogger
import asyncio
agent = await spawn(premise="You are helpful.")
stream = StreamLogger()
with stream:
result = asyncio.create_task(
agent.call(bool, "Is Paris the capital of France?")
)
# Consume stream FIRST for live outputasyncfor chunk in stream:
print(chunk.content, end="", flush=True)
# chunk.role is 'user', 'agent', or 'system'# Then await result
final = await result