Adapters overview
Adapters connect your agent code to the Astro AI runtime. They translate your framework’s events into the messaging protocol — status updates, content chunks, audio, and feedback — so you keep using whatever framework you already chose. You write serve(myAgent); the adapter handles the rest.
Choose an adapter
When you call LLM APIs directly, treat the LLM stream as your fullStream. To reach Astro AI messaging from a non-agent process (admin or batch), skip the adapter and use the Messaging SDK directly — the same SDK you work with when writing a custom adapter.
The *-core packages contain the framework-agnostic AgentAdapter interface and a serve() entry point. The framework adapters (-mastra, -langchain) are thin wrappers that translate framework-specific stream events (Mastra fullStream chunks, LangChain astream updates) into the shared StreamHooks lifecycle.
What an adapter handles for you
- Connecting to Astro AI messaging with automatic reconnect.
- Announcing your agent’s name, system prompt, and tools so they appear in the playground.
- Streaming each user message into your code and streaming each chunk of the reply back.
- Receiving feedback (thumbs up/down, free-form text, button clicks) and routing it to your handler.
- Handling audio messages — STT before your agent runs, optional TTS on the reply.
- Tracing — when an OTEL endpoint is set, the framework adapters auto-wire it.
Environment
All adapters share the same environment contract:
Local development with ast dev injects GRPC_SERVER_ADDR so the same serve(agent) call works both locally and in production.