Atomic Agents
БесплатноБез исполняемых скриптовНе проверенThis skill should be used when the user asks to "create an agent", "configure AtomicAgent", "set up agent", "agent configuration", "AgentConfig"…
от majiayu000★ 31 звезда на GitHubОб этом скилле
Atomic Agents Agent Configuration
The AtomicAgent is the core class for LLM interactions in the Atomic Agents framework. It handles structured input/output, conversation history, and system prompt management.
Basic Agent Setup
import instructor
import openai
from atomic_agents.agents.base_agent import AtomicAgent, AgentConfig
from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator
from atomic_agents.lib.components.chat_history import ChatHistory
# 1. Create instructor-wrapped client
client = instructor.from_openai(openai.OpenAI())
# 2. Configure the agent
config = AgentConfig(
client=client,
model="gpt-4o-mini",
history=ChatHistory(),
system_prompt_generator=SystemPromptGenerator(
background=["You are an expert assistant."],
steps=["1. Analyze the input.", "2. Generate response."],
output_instructions=["Be concise and helpful."],
),
)
# 3. Create the agent with type parameters
agent = AtomicAgent[InputSchema, OutputSchema](config=config)
AgentConfig Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
client |
Instructor client | Yes | Instructor-wrapped LLM client |
model |
str | Yes | Model identifier (e.g., "gpt-4o-mini") |
history |
ChatHistory | No | Conversation history manager |
system_prompt_generator |
SystemPromptGenerator | No | System prompt configuration |
input_schema |
BaseIOSchema | No | Override input schema |
output_schema |
BaseIOSchema | No | Override output schema |
model_api_parameters |
dict | No | Additional API parameters |
LLM Provider Setup
OpenAI
import instructor
import openai
client = instructor.from_openai(openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY")))
model = "gpt-4o-mini" # or "gpt-4o", "gpt-4-turbo"
Anthropic
import instructor
import anthropic
client = instructor.from_anthropic(anthropic.Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY")))
model = "claude-sonnet-4-20250514"
Groq
import instructor
from groq import Groq
client = instructor.from_groq(Groq(api_key=os.getenv("GROQ_API_KEY")), mode=instructor.Mode.JSON)
model = "llama-3.1-70b-versatile"
Ollama (Local)
import instructor
import openai
client = instructor.from_openai(
openai.OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
)
model = "llama3.1"
Agent Execution Methods
Synchronous
output = agent.run(InputSchema(message="Hello"))
Asynchronous
output = await agent.run_async(InputSchema(message="Hello"))
Streaming (Sync)
for partial in agent.run_stream(InputSchema(message="Hello")):
print(partial) # Partial responses as they arrive
Streaming (Async)
async for partial in agent.run_async_stream(InputSchema(message="Hello")):
print(partial)
ChatHistory Management
from atomic_agents.lib.components.chat_history import ChatHistory
# Create history
history = ChatHistory()
# Use with agent
config = AgentConfig(client=client, model=model, history=history)
agent = AtomicAgent[InputSchema, OutputSchema](config=config)
# Run multiple turns (history accumulates)
agent.run(InputSchema(message="Hello"))
agent.run(InputSchema(message="Tell me more"))
# Reset history
agent.reset_history()
# Save/load history
history_data = history.to_dict()
new_history = ChatHistory.from_dict(history_data)
Context Providers
Dynamic context injection into system prompts:
from atomic_agents.lib.components.system_prompt_generator import BaseDynamicContextProvider
class UserContextProvider(BaseDynamicContextProvider):
def __init__(self):
super().__init__(title="User Context")
self.user_name = ""
def get_info(self) -> str:
return f"Current user: {self.user_name}"
# Register with agent
provider = UserContextProvider()
agent.register_context_provider("user", provider)
# Update context dynamically
provider.user_name = "Alice"
agent.run(input_data) # System prompt now includes user context
Token Counting
# Get token usage
token_info = agent.get_context_token_count()
print(f"Total: {token_info.total}")
print(f"System prompt: {token_info.system_prompt}")
print(f"History: {token_info.history}")
print(f"Utilization: {token_info.utilization:.1%}")
Hooks for Monitoring
def on_response(response):
print(f"Got response: {response}")
def on_error(error):
print(f"Error: {error}")
agent.register_hook("completion:response", on_response)
agent.register_hook("completion:error", on_error)
agent.register_hook("parse:error", on_error)
Hook events:
completion:kwargs- Before API callcompletion:response- After successful responsecompletion:error- On API errorparse:error- On parsing/validation error
Model API Parameters
Pass additional parameters to the LL
Установить Atomic Agents в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл Atomic Agents?
This skill should be used when the user asks to "create an agent", "configure AtomicAgent", "set up agent", "agent configuration", "AgentConfig", "ChatHistory", or needs guidance on agent initialization, model selection, history management, and agent execution patterns for Atomic Agents applications.
Как установить скилл Atomic Agents?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Atomic Agents запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic