cd /news/ai-agents/building-cross-language-ai-agents-wi… · home › topics › ai-agents › article
[ARTICLE · art-173658] src=pub.towardsai.net ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Building Cross-Language AI Agents with Spring AI, Google ADK, and A2A

A tutorial published in early October 2026 demonstrates building cross-language AI agents by pairing a Spring AI coordinator written in Java with a Google Agent Development Kit (ADK) specialist in Python, connected through the Agent2Agent (A2A) protocol rather than custom REST endpoints. The example pins google-adk[a2a]==2.9.2, a2a-sdk[http-server]==1.1.4, and Python 3.12, and keeps only two steps as model inference — the coordinator selecting the researchSupplier tool and the specialist executing its domain tool — while discovery, serialization, timeouts, and error handling stay in deterministic code. The pattern targets enterprises where Java owns customer-facing APIs, identity, and policy and Python owns model experimentation, turning each new agent integration into a configuration task instead of a custom software project.

recommendation

Put the agent boundary on A2A instead of custom REST: let the coordinator read the specialist's Agent Card and dispatch A2A messages, keeping endpoint selection and error handling in code so the model cannot invoke arbitrary endpoints.

more in playbook: Designing agent systems
by read9 min views8 publishedNov 21, 2026

Enterprise AI rarely exists in a single language, making building cross-language AI agents essential for modern architectures. Java typically manages customer-facing APIs, identity, policy, and long-running business services. Python handles model experimentation, data tooling, and specialist agent workflows. Connecting the two with bespoke REST endpoints creates an unstandardized, private protocol that both teams must continuously maintain.

The Agent2Agent (A2A) protocol offers a more durable boundary. This article builds a Spring AI coordinator in Java that delegates supplier research to a Google Agent Development Kit (ADK) specialist in Python. The frameworks stay independent; the network contract becomes the integration point.

A standardized agent boundary transforms each new agent integration from a custom software project into a straightforward configuration task. The primary business benefits emerge in four key areas:

This integration pattern is suitable wherever a governed Java front door must invoke specialist reasoning owned by a separate team. When building cross-language AI agents, the primary scenario is detailed in the first row of the table below, while the additional use cases follow an identical structure.

In each case, the coordinator keeps the final decision and the human-review policy. The specialist supplies evidence, not verdicts.

When a user requests a supplier assessment through the Java API, the Spring AI coordinator determines that external research is required and invokes the researchSupplier tool. The adapter reads the specialist’s Agent Card, dispatches an A2A message, and returns the result. Finally, the coordinator separates the remote findings from its own internal inference.

Only two steps involve model inference: the coordinator selecting the appropriate tool, and the specialist determining how to execute its domain tool. Discovery, endpoint selection, serialization, timeouts, and error handling remain in deterministic code, preventing the model from invoking arbitrary endpoints.

While a standard REST endpoint eliminates runtime coupling, development teams must still define custom semantics for discovery, task states, streaming, artifacts, and error handling. The A2A protocol standardizes these core agent concepts while maintaining abstraction over remote implementations. Consequently, Spring AI only requires knowledge of the specialist’s capabilities and endpoint location, without needing visibility into its prompts, models, or state management.

The example was verified against the versions below as of early October 2026. Pin them in your build files; protocol SDKs and framework integrations move quickly.

You need an API key for the model behind Spring AI and a Google API key (or Google Cloud credentials) for Gemini. The supplier data is a local fixture, so no third-party research API is required.

The following implementation code is fully executable as presented. Install Google ADK alongside its A2A extension and pin the A2A SDK to ensure explicit transport versioning:

mkdir supplier-agent && cd supplier-agentuv init --package --python 3.12uv add "google-adk[a2a]==2.9.2" "a2a-sdk[http-server]==1.1.4" uvicorn

The underlying tool returns a deterministic fixture to allow testing of the bridge without external dependencies. The system prompt explicitly identifies this data, ensuring the model does not present demonstration fixtures as live operational research.

Google ADK’s to_a2a() function encapsulates an existing agent as an A2A service and automatically generates its Agent Card. Because ADK 2.9.2 designates its A2A integration as experimental, explicit dependency versioning should be maintained. Start the service and verify discovery as follows:

export GOOGLE_API_KEY="replace-me"uv run uvicorn supplier_agent.agent:a2a_app --host 0.0.0.0 --port 8001# In another terminalcurl -H "A2A-Version: 1.0" http://localhost:8001/.well-known/agent-card.json

The card lists the agent’s skills, input and output modes, and its endpoints. Under A2A 1.0, endpoints appear in a supportedInterfaces array, each declaring its own protocol binding and version.

The Java implementation below is fully executable (with package declarations and imports omitted from the secondary snippet for brevity). To maintain clear architecture boundaries, the table below outlines framework-provided elements versus custom application code.

The example does not depend on any A2A support inside Spring AI. It uses plain HTTP so every protocol detail is visible.

pom.xml (dependencies)

<parent>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-parent</artifactId>    <version>4.1.1</version></parent><dependencyManagement>    <dependencies>        <dependency>            <groupId>org.springframework.ai</groupId>            <artifactId>spring-ai-bom</artifactId>            <version>2.0.1</version>            <type>pom</type>            <scope>import</scope>        </dependency>    </dependencies></dependencyManagement><dependencies>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-webmvc</artifactId>    </dependency>    <dependency>        <groupId>org.springframework.ai</groupId>        <artifactId>spring-ai-starter-model-openai</artifactId>    </dependency></dependencies>

application.yml

spring.ai.openai:  api-key: ${OPENAI_API_KEY}  chat.model: ${OPENAI_MODEL}agents.supplier:  card-url: http://localhost:8001/.well-known/agent-card.json  allowed-hosts: localhost

The OpenAI starter is only an example. Any Spring AI chat model that supports tools can drive the adapter.

Annotation-based tools in Spring AI are synchronous, so the adapter blocks at the tool boundary with fixed timeouts. Every request carries the A2A-Version: 1.0 header, which the A2A 1.0 specification (section 3.6.1) requires clients to send; a server that receives no header must assume version 0.3.

package com.example.coordinator;import java.net.URI;import java.net.http.HttpClient;import java.time.Duration;import java.util.*;import org.springframework.ai.tool.annotation.Tool;import org.springframework.ai.tool.annotation.ToolParam;import org.springframework.beans.factory.annotation.Value;import org.springframework.core.ParameterizedTypeReference;import org.springframework.http.MediaType;import org.springframework.http.client.JdkClientHttpRequestFactory;import org.springframework.stereotype.Component;import org.springframework.web.client.RestClient;@Componentpublic class A2aResearchTool {    private static final ParameterizedTypeReference<Map<String, Object>> JSON =        new ParameterizedTypeReference<>() {};    private final RestClient http;    private final URI cardUri;    private final Set allowedHosts;    public A2aResearchTool(        @Value("${agents.supplier.card-url}") URI cardUri,        @Value("${agents.supplier.allowed-hosts}") Set allowedHosts) {        var factory = new JdkClientHttpRequestFactory(            HttpClient.newBuilder()                .connectTimeout(Duration.ofSeconds(5))                .build());        factory.setReadTimeout(Duration.ofSeconds(45));        this.http = RestClient.builder()            .requestFactory(factory)            .defaultHeader("A2A-Version", "1.0")            .build();        this.cardUri = cardUri;        this.allowedHosts = allowedHosts;    }    @Tool(description = "Research a supplier through the remote specialist agent")    public String researchSupplier(        @ToolParam(description = "Legal or trading company name") String company,        @ToolParam(description = "Country of operation") String country) {        Map<String, Object> request = Map.of(            "jsonrpc", "2.0",            "id", UUID.randomUUID().toString(),            "method", "SendMessage",            "params", Map.of("message", Map.of(                "messageId", UUID.randomUUID().toString(),                "role", "ROLE_USER",                "parts", List.of(Map.of("text",                    "Assess supplier " + company + " in " + country)))));        Map<String, Object> response = http.post().uri(resolveEndpoint())            .contentType(MediaType.APPLICATION_JSON)            .body(request).retrieve().body(JSON);        if (response == null || response.containsKey("error")) {            throw new IllegalStateException("A2A call failed: " + response);        }        return String.valueOf(response.get("result"));    }    /** Reads the Agent Card and returns a JSON-RPC endpoint on an allowed host. */    @SuppressWarnings("unchecked")    private URI resolveEndpoint() {        Map<String, Object> card = http.get().uri(cardUri).retrieve().body(JSON);        var interfaces = (List<Map<String, Object>>)            card.getOrDefault("supportedInterfaces", List.of());        return interfaces.stream()            .filter(i -> "JSONRPC".equals(i.get("protocolBinding")))            .map(i -> URI.create((String) i.get("url")))            .filter(u -> allowedHosts.contains(u.getHost()))            .findFirst()            .orElseThrow(() ->new IllegalStateException("No allowed JSON-RPC endpoint"));    }}

The host allowlist provides necessary security control: the model determines business parameters while deterministic code enforces target endpoints. For production implementations, this custom client should be replaced with the official A2A Java SDK, which provides strongly typed domain models, Agent Card caching, and comprehensive task state management.

@Configurationclass ChatConfiguration {    @Bean    ChatClient coordinator(ChatClient.Builder builder, A2aResearchTool researchTool) {        return builder.defaultSystem("""                You assess supplier risk for a human reviewer.                Use researchSupplier before writing an assessment.                Keep remote findings separate from your own inference.                Never approve or reject a supplier.""")            .defaultTools(researchTool)            .build();    }}@RestControllerclass AssessmentController {    private final ChatClient coordinator;    AssessmentController(ChatClient coordinator) {        this.coordinator = coordinator;    }    record AssessmentRequest(String company, String country) {}    @PostMapping("/api/assessments")    Map<String, String> assess(@RequestBody AssessmentRequest req) {        String answer = coordinator.prompt()            .user("Assess " + req.company() + " in " + req.country())            .call().content();         return Map.of("assessment", answer);    }}

Spring AI’s auto-registered ToolCallingAdvisor runs the model-and-tool loop until the model returns a final answer. Spring AI 2.0.1 also adds a configurable cap on tool calls per request, worth setting in production.

With the Python service running, start Spring and send one request:

export OPENAI_API_KEY="replace-me"export OPENAI_MODEL="a-tool-capable-model"./mvnw spring-boot:runcurl -X POST http://localhost:8080/api/assessments \  -H "Content-Type: application/json" \  -d '{"company":"Northwind Components","country":"India"}'

Although response phrasing varies by model, the final output should cite the demonstration data source, summarize the three fixture signals, and request human verification. If the coordinator issues a final procurement decision, refine the system instructions and implement automated policy checks.

During troubleshooting, invoke the Python agent directly to isolate transport and specialist errors from Spring AI tool selection issues. Target the endpoint URL specified in the Agent Card using the updated A2A 1.0 specification naming, where message/send has been renamed to SendMessage and the redundant kind field has been removed:

curl -X POST <JSONRPC-url-from-agent-card> \  -H "Content-Type: application/json" \  -H "A2A-Version: 1.0" \  -d '{"jsonrpc":"2.0","id":"debug-1","method":"SendMessage",       "params":{"message":{"messageId":"msg-1","role":"ROLE_USER",       "parts":[{"text":"Assess Northwind in India"}]}}}'

The open-source A2A Inspector and Technology Compatibility Kit (TCK) offer dedicated tools for interactive protocol inspection and compliance validation during SDK upgrades.

A successful demonstration confirms baseline connectivity but does not guarantee operational resilience. Before introducing the adapter into production workflows, address and validate the following operational requirements:

Adopt A2A when organisational independence is as critical as technical decoupling: distinct engineering teams manage each agent, specialists scale and deploy independently, and internal tools or prompts remain encapsulated. A2A complements the Model Context Protocol (MCP), which standardises agent-to-tool connections rather than inter-agent communication.

Skip it when the operation is deterministic with a stable API, or when both parts share a release cycle. A single lookup is a tool, not an agent.

Agent interoperability is moving from experiment to infrastructure. Five shifts are worth planning for:

Java and Python agents can effectively collaborate without sharing a common runtime or framework ecosystem. Spring AI manages orchestration, policy enforcement, and client delivery; Google ADK governs specialist reasoning and domain tools; and A2A provides the standardized protocol for discovery, messaging, task lifecycle management, and artifact transfer.

The adapter pattern demonstrated in this article establishes a baseline integration in approximately 60 lines of code. Enterprise deployments should extend this foundation with the official A2A Java SDK, mutual authentication, persistent task state, distributed tracing, strict schema validation, and contract testing suites. With these controls established, independent engineering teams can safely evolve cross-language agent systems against a stable specification.

This article was supported by AI-based research and writing, with Claude 5 assisting in the creation of text and images.

Saleen Theeyons is a Senior Software Engineer at CapeStart with 11+ years of experience in software engineering, specializing in Java, Spring Boot, microservices, and backend development. Passionate about Artificial Intelligence (AI) and Generative AI, he explores emerging technologies and how intelligent tools can enhance software development practices, improve productivity, and drive innovation. He enjoys experimenting with modern technologies and sharing practical insights through technical articles, focusing on the evolving landscape of software engineering and the growing impact of AI on application development.

Building Cross-Language AI Agents with Spring AI, Google ADK, and A2A was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

── more in #ai-agents 4 stories · sorted by recency
── more on @spring ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/building-cross-langu…] indexed:0 read:9min 2026-11-21 · —