Building AI agents, atomically
Communication & Integrations
Last Updated: 2026-10-24
The framework exposes no HTTP API of its own; "communication" here means how it talks to LLM providers and external tools.
LLM providers (via Instructor)
- All model calls go through an Instructor-wrapped client the caller supplies
(
instructor.from_openai(...),from_anthropic(...), etc.). The agent callsclient.chat.completions.create(response_model=OutputSchema)(andcreate_partialfor streaming). - Provider-agnostic: OpenAI, Anthropic, Google Gemini, MiniMax, and 100+ models via LiteLLM. Mode is
configurable (
Mode.TOOLSis the default). - Multimodal content uses Instructor's Image/Audio/PDF types plus the framework's
VideoURL;ChatHistory.get_history()convertsVideoURLto an OpenAI-compatiblevideo_urldict, which Instructor forwards unchanged to providers that support video inputs. - Provider quirks live in
AgentConfig:system_role,assistant_role(use"model"for Gemini),tool_result_role(auto-detected). - Code:
atomic-agents/atomic_agents/agents/atomic_agent.py.
Token accounting (via LiteLLM)
atomic-agents/atomic_agents/utils/token_counter.pyuses LiteLLM'stoken_counterfor provider-agnostic counts, which drive the context-window trimming inAtomicAgent. Video content parts are represented by a[video content]text placeholder because LiteLLM cannot count them.
MCP — Model Context Protocol
atomic-agents/atomic_agents/connectors/mcp/turns MCP server capabilities into agent tools/resources/prompts:MCPFactory,MCPDefinitionService,SchemaTransformer, andfetch_mcp_tools/fetch_mcp_resources/fetch_mcp_prompts(sync + async). See themcp-agentandprogressive-disclosureexamples.- Discovery follows tool, resource, template and prompt cursors. Template continuation errors propagate.
- Schema references decode escaped definition names and support non-object definitions.
- Typed SDK tool results use structured content only when it is non-None, then use the existing validated JSON-text fallback. Present empty structured data retains precedence. Mapping adapters keep their separate validation contract.
- SDK
CallToolResultand strictly validated mapping envelopes withisError=Trueraise aRuntimeErrorbefore typed or generic output parsing. The message usesTextContentonly (meaningful fallback when no text);structuredContent,_metaand binary blocks never enter messages or logs. Raw application dictionaries that merely containisError/namekeys (even with a stringcontent) stay ordinary outputs.
Hooks / observability
- Built on Instructor's hook system:
register_hook(event, handler),unregister_hook,clear_hooks. Events includeparse:error,completion:kwargs,completion:response,token:counted. See thehooks-exampleexample anddocs/guides/hooks.md. disable_hooks()detaches this agent's registered Instructor callbacks. Registrations made while disabled stay paused;enable_hooks()restores the remaining callbacks. Direct client callbacks and tracing hooks remain independent.- OpenTelemetry tracing (
atomic_agents.observability,observabilityextra =opentelemetry-apionly): an AGENT span perAtomicAgentrun, a TOOL span perBaseToolrun and one CLIENTchatspan per Instructor attempt (driven by Instructor hooks registered once per client), all with OpenTelemetry GenAI attributes; OpenInference attributes are added only when its package is importable (phoenixextra). Activated byphoenix.otel.register(auto_instrument=True)throughopeninference_instrumentor, by theopentelemetry-instrumentlauncher throughopentelemetry_instrumentor, or byAtomicAgentsInstrumentor().instrument(tracer_provider=..., config=TracingConfig(...)). A later install with different explicit values replaces the provider/config in place with a WARNING;Nonekeeps the installed value. Missingopentelemetry-apiis DEBUG-skipped when the launcher passesskip_dep_check=True; manual setup raisesModuleNotFoundErrorwith the install hint. Application hooks on the same client keep running;AtomicAgent.clear_hooks()removes only its own. Setllm_spans=False(orATOMIC_AGENTS_TRACE_LLM_SPANS=false) when a provider instrumentor also emits LLM spans. Seedocs/guides/observability.mdand thephoenix-tracingexample. - Forge tools that run their async body through a
ThreadPoolExecutorsubmit viacontextvars.copy_context().runso the caller's OpenTelemetry context (and the tracing re-entrancy guard) survives in the pool thread.
Assembler ↔ GitHub
atomic-assemblercloneshttps://github.com/eigenwise/atomic-agents.git(via GitPython), readsatomic-forge/tools/, and copies the chosen tool into the user's project (skipping build files). Source URL and paths are inatomic-assembler/atomic_assembler/constants.pyandutils.py(GithubRepoCloner,AtomicToolManager).