Demo: Build and deploy a multi-agent system with Akka
4 minute read
Short: 5 minutes
Complete: 15 minutes
Short version
In this demo, we build an agent with intrinsic memory, an HTTP endpoint, and deployed to a 3 node cluster. We use Claude Code to facilitate the rapid creation in minutes.
Complete version
In this demo, we build, run and evaluate an agentic system with Akka and Claude Code. It contains agents, memory, endpoints, orchestration, and streaming. The system is deployed as a 3 node cluster for resilience, and then deployed into GCP and AWS for multi-region failover and disaster recovery.
Akka SDK preconfigured CLAUDE.md for Claude memory.
Prompts
Add a agent
Create an Akka SDK agent named `GreetingAgent`
that assists users in learning greetings in different languages.
- **Input:** A string question.
- **Output:** Returns an `Effect<String>`.
- method with name `ask`
- Do not perform any environment variables check.
- Do not add JavaDoc annotations
- place it into com.example.application package
- system message should be a static variable
- **Guidelines for system prompt:**
- The user must provide a language.
- Always append the language used in parentheses in English (e.g.,
"Bonjour (French)").
- At the end of each response, append a list of previous greetings used in
the current session.
Test agent
Develop only one integration test for `GreetingAgent`
in the `com.example` package, named `IntegrationTest`.
- Include a `TestModelProvider` to mock the model with a fixed response.
- Ensure all necessary classes are properly imported.
Add endpoint
Implement an HTTP endpoint `GreetingAgentEndpoint` with the following
specifications:
- **Base path:** `/chat`
- **Endpoint:** POST `/ask`
- **Request:** Accepts a JSON record `QueryRequest` with fields `String userId`
and `String question`.
- Put the QueryRequest in the GreetingAgentEndpoint class
- The agent should use `userId` as the sessionId and `question` as the
user message.
- add acl for all access
Add MCP endpoint
Create an MCP server endpoint named `UserNameMcpEndpoint`
for retrieving user's name based on `userId`.
- Place the implementation in the `com.example.api` package.
- Provide a mock implementation that returns a random name for each query.
- add all needed annotations (class and method)
- use MCP Tool annotations with all required parameters including the
McpEndpoint annotation
Add MCP tool to an agent
Update the `GreetingAgent` to display the user's name during the first
interaction, for example: "Hello <user name>!".
- Configure GreetingAgent to use `UserNameMcpEndpoint` as an MCP tool. No need
to use AllowedToolNames. Use the service name specified by the `artifactId` in
`pom.xml`.
- set `userId` from context().sessionId().
- Add the `userId` to the user message in the following format: "userId:<userId>
;question:
- update system prompt accordingly
Add streaming
Update the `GreetingAgent` to display the user's name during the first
interaction, for example: "Hello <user name>!".
- Configure GreetingAgent to use `UserNameMcpEndpoint` as an MCP tool. No need
to use AllowedToolNames. Use the service name specified by the `artifactId` in
`pom.xml`.
- set `userId` from context().sessionId().
- Add the `userId` to the user message in the following format: "userId:<userId>
;question:
- update system prompt accordingly
Posts by this author