Skip to content

CrewAI

AgentRuntime for the CrewAI multi-agent framework. Java does not embed Python — instead the runtime talks to a CrewAI sidecar process over HTTP + SSE. This is the same pattern many JVM teams use to bring Python-native agent frameworks (CrewAI, AutoGen, LlamaIndex) into Java services without rewriting the agent logic.

<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-crewai</artifactId>
<version>${project.version}</version>
</dependency>

Drop the dependency alongside atmosphere-ai and the framework auto-detects it via ServiceLoader. CrewAiAgentRuntime drives the sidecar; streamed tokens flow back to the StreamingSession:

@AiEndpoint(path = "/ai/chat", systemPrompt = "You are a helpful assistant")
public class MyChat {
@Prompt
public void onPrompt(String message, StreamingSession session) {
session.stream(message); // dispatched to the CrewAI sidecar
}
}

The Python sidecar (atmosphere-crewai-bridge, shipped in the module’s sidecar/ directory) speaks the wire protocol and materialises Java @AiTool descriptors as native crewai.tools.BaseTool subclasses.

The runtime stays unavailable out of the box: isAvailable() returns false until you point ATMOSPHERE_CREWAI_SIDECAR_URL at a running sidecar that responds OK to GET /health. This is deliberate (Runtime Truth) — the runtime never advertises availability based on the classpath alone.

Terminal window
export ATMOSPHERE_CREWAI_SIDECAR_URL=http://localhost:8089

When CrewAI invokes a Java @AiTool, the sidecar POSTs back to a loopback-only ToolCallbackServer inside the JVM. Those calls route through ToolExecutionHelper.executeWithApproval, so approval gates, validation, and governance apply identically to the in-process tool path. context.systemPrompt() is threaded into every agent’s backstory inside a delimited block so the directive stays distinguishable from user prose.

Cancellation is process-less: cancelling the session issues a DELETE on the sidecar session id rather than killing a process.

  • Spring Boot AI Chat — drop atmosphere-crewai on the classpath and point ATMOSPHERE_CREWAI_SIDECAR_URL at a running sidecar
  • AI ReferenceAgentRuntime SPI, @AiEndpoint, capability matrix, tool calling
  • Module README — wire protocol, sidecar setup, test suites