|
| 1 | +--- |
| 2 | +title: Atmosphere |
| 3 | +sidebar_position: 50 |
| 4 | +hide_title: true |
| 5 | + |
| 6 | +level: intermediate |
| 7 | +status: published |
| 8 | +visibility: public |
| 9 | + |
| 10 | +external-link: https://github.com/Atmosphere/atmosphere |
| 11 | +programming-language: "Java" |
| 12 | +--- |
| 13 | + |
| 14 | +# Atmosphere |
| 15 | + |
| 16 | +**<h2><a href="https://github.com/Atmosphere/atmosphere" target="_blank" rel="noopener noreferrer">👉 Visit Atmosphere on GitHub ↗</a></h2>** |
| 17 | + |
| 18 | +[Documentation](https://atmosphere.github.io/docs/) · [Tutorial](https://atmosphere.github.io/docs/tutorial/01-introduction/) · [Samples](https://github.com/Atmosphere/atmosphere/tree/main/samples) |
| 19 | + |
| 20 | +Atmosphere is a real-time transport abstraction framework for Java. It handles WebSocket, SSE, HTTP long-polling, and gRPC — with automatic transport negotiation, message caching, reconnection, and clustering. Built and maintained over many years. |
| 21 | + |
| 22 | +The AI agent layer was built on top of that foundation. An `@Agent` class defines prompts, commands, and tools. The AI execution engine — tool calling, memory, RAG, retries — is pluggable via the `AgentRuntime` SPI and determined by classpath: Spring AI, LangChain4j, Google ADK, or Embabel. The framework also handles protocol exposure (MCP, A2A, AG-UI) and messaging channels (Slack, Telegram, Discord). |
| 23 | + |
| 24 | +## Architecture |
| 25 | + |
| 26 | +Atmosphere follows the Servlet model: application code is separate from the execution engine. |
| 27 | + |
| 28 | +| Servlet analogy | Atmosphere equivalent | |
| 29 | +|-----------------|----------------------| |
| 30 | +| `Servlet` / `@Controller` | `@Agent` / `@Prompt` | |
| 31 | +| Tomcat, Jetty, Undertow | LangChain4j, Spring AI, ADK, Embabel | |
| 32 | +| `AsyncSupport` (container SPI) | `AgentRuntime` (framework SPI) | |
| 33 | +| HTTP, WebSocket | MCP, A2A, AG-UI | |
| 34 | +| `web.xml` / annotations | Skill files (Markdown + YAML) | |
| 35 | + |
| 36 | +The `@Agent` class declares what the agent does. The `AgentRuntime` on the classpath determines how it executes: tool calling loops, conversation memory, RAG retrieval, retries, and guardrails. |
| 37 | + |
| 38 | +## Supported Runtimes |
| 39 | + |
| 40 | +| Runtime | Module | Capabilities | |
| 41 | +|---------|--------|-------------| |
| 42 | +| **Built-in** | `atmosphere-ai` | OpenAI-compatible client (Gemini, OpenAI, Ollama) | |
| 43 | +| **LangChain4j** | `atmosphere-langchain4j` | ReAct tool loops, `StreamingChatModel`, retries. `@AiTool` methods bridged to LangChain4j tools. | |
| 44 | +| **Spring AI** | `atmosphere-spring-ai` | `ChatClient`, function calling, RAG advisors | |
| 45 | +| **Google ADK** | `atmosphere-adk` | `LlmAgent`, function tools, session management | |
| 46 | +| **Embabel** | `atmosphere-embabel` | Goal-driven GOAP planning (experimental) | |
| 47 | + |
| 48 | +Switching runtimes requires changing one Maven dependency. Agent code, tools, commands, and skill files remain the same. |
| 49 | + |
| 50 | +## Framework Capabilities |
| 51 | + |
| 52 | +These work regardless of which `AgentRuntime` is active: |
| 53 | + |
| 54 | +- **Real-time streaming** — LLM tokens delivered via WebSocket/SSE |
| 55 | +- **Protocol exposure** — MCP, A2A, and AG-UI endpoints auto-register from classpath |
| 56 | +- **Multi-agent orchestration** — `@Coordinator` + `@Fleet` for parallel fan-out, sequential pipelines, coordination journal |
| 57 | +- **Conversation memory** — multi-turn context persisted to SQLite or Redis |
| 58 | +- **Tool portability** — `@AiTool` methods work across all runtimes |
| 59 | +- **Skill files** — Markdown with YAML frontmatter for agent persona, tools, guardrails, and channel routing |
| 60 | +- **Messaging channels** — Slack, Telegram, Discord, WhatsApp, Messenger via bot token configuration |
| 61 | +- **Servlet integration** — runs as a filter in Spring Boot, Quarkus, or any Servlet 6.0+ container |
| 62 | + |
| 63 | +## Quick Start |
| 64 | + |
| 65 | +The Atmosphere CLI scaffolds new projects and runs existing samples directly: |
| 66 | + |
| 67 | +```bash |
| 68 | +brew install Atmosphere/tap/atmosphere |
| 69 | + |
| 70 | +# Scaffold a new project |
| 71 | +atmosphere new my-agent --template ai-chat |
| 72 | +cd my-agent && LLM_API_KEY=your-key ./mvnw spring-boot:run |
| 73 | + |
| 74 | +# Or run any of the 18 built-in samples |
| 75 | +atmosphere list |
| 76 | +atmosphere run spring-boot-ai-chat |
| 77 | +``` |
| 78 | + |
| 79 | +```java |
| 80 | +@Agent(name = "my-agent", description = "What this agent does") |
| 81 | +public class MyAgent { |
| 82 | + |
| 83 | + @Prompt |
| 84 | + public void onMessage(String message, StreamingSession session) { |
| 85 | + session.stream(message); // Dispatches to active AgentRuntime |
| 86 | + } |
| 87 | + |
| 88 | + @Command(value = "/status", description = "Show status") |
| 89 | + public String status() { |
| 90 | + return "All systems operational"; |
| 91 | + } |
| 92 | + |
| 93 | + @AiTool(name = "lookup", description = "Look up data") |
| 94 | + public String lookup(@Param("query") String query) { |
| 95 | + return "Result for: " + query; |
| 96 | + } |
| 97 | +} |
| 98 | +``` |
| 99 | + |
| 100 | +## Protocol Support |
| 101 | + |
| 102 | +| Protocol | Standard | |
| 103 | +|----------|----------| |
| 104 | +| MCP | Model Context Protocol | |
| 105 | +| A2A | Agent-to-Agent Protocol | |
| 106 | +| AG-UI | Agent-User Interaction Protocol | |
| 107 | + |
| 108 | +Protocols auto-register based on classpath detection. |
| 109 | + |
| 110 | +## Requirements |
| 111 | + |
| 112 | +Java 21+. Spring Boot 4.0, Quarkus 3.21, or any Servlet 6.0+ container. |
| 113 | + |
| 114 | +## Related Resources |
| 115 | + |
| 116 | +- [A2A Protocol](./40-a2a-protocol.md) — Atmosphere implements A2A for agent-to-agent communication |
| 117 | +- [Google ADK](./10-adk.md) — supported as an AgentRuntime backend |
0 commit comments