Google ADK A2A Tutorial: Connect Python and Go AI Agents

Google ADK A2A tutorials: Google ADK A2A workflow connecting Python contract extraction with Go policy validation

Google Shows How Python and Go AI Agents Can Work as One

Google published a practical cross-language agent tutorial on June 22, 2026, showing how a Python service and a Go service can participate in one contract-compliance workflow through the Agent2Agent protocol.

The architecture solves a common enterprise problem. A data or AI team may build document processing in Python, while a platform or security team maintains policy logic in Go. Rewriting either component creates cost and risk.

Google’s example uses its Agent Development Kit, or ADK, to orchestrate the workflow. A Python service extracts structured contract information and sends it to a remote Go service. The Go service applies deterministic compliance rules and returns an auditable verdict. A2A provides discovery and communication between the two separately deployed components.


What This Google ADK A2A Tutorial Demonstrates


The Google ADK A2A tutorial builds a contract-compliance pipeline with two clear responsibilities.

The Python side handles:

  • Contract intake
  • Extraction of relevant fields
  • Risk classification
  • Session state and artifacts
  • Workflow orchestration
  • Communication with the remote service

The Go side handles:

  • Contract-value limits
  • Maximum contract duration
  • Insurance requirements
  • Exit-clause requirements
  • Unlimited-liability restrictions
  • Renewal-policy checks

The official repository describes the Go component as a deterministic policy agent rather than an LLM agent. That design makes its decisions repeatable and easier to test.

In a production version, Gemini could extract ambiguous information from unstructured legal text. The downloadable demonstration also includes deterministic fixtures so developers can run the workflow without a Gemini API key.


Architecture: Where Each Component Fits


The workflow can be represented as:

User or contract system

|

v

Python FastAPI service

|

+–> extraction and normalization

|

+–> ADK coordinator

|

v

RemoteA2aAgent

|

A2A / JSON-RPC

|

v

Go compliance service

|

deterministic policy engine

|

v

pass, review, or violations

|

v

Python report and artifacts

Python and Go agent workflow using Google ADK and A2A
Python interprets the contract; Go applies repeatable policy rules.

Google’s sample runs the Python service on one endpoint and the Go service on another. The Go service publishes an agent card describing its identity and capability. The Python side reads that card and treats the remote A2A service like a sub-agent inside the wider ADK workflow.


How A2A Discovery Works


A2A-compliant agents publish an agent card at a well-known endpoint.

The card describes what the agent does and how another service can contact it. Google’s Go launcher can generate this metadata dynamically when exposing an ADK agent. The consuming service uses the card location to initialize a remote-agent connection.

A simplified card might look like this:

{

“name”: “contract_compliance_agent”,

“description”: “Validates extracted contract fields”,

“url”: “https://compliance.internal.example”,

“capabilities”: {

“streaming”: false

}

}

The exact schema depends on the A2A specification and SDK version. Production code should validate the card rather than trusting arbitrary discovery metadata.

A2A is designed to let independently built agents discover capabilities, exchange supported content types, collaborate on tasks, and remain opaque about their internal tools or memory.


The Python Extraction and Orchestration Layer


Python is a natural fit for document processing because it has mature libraries for machine learning, text analysis, APIs, and data transformation.

In the conceptual workflow, the extraction step should convert contract language into a strict internal object such as:

{

“contract_id”: “vendor-2026-014”,

“value_usd”: 425000,

“term_years”: 4,

“insurance_usd”: 2000000,

“has_exit_clause”: true,

“unlimited_liability”: false,

“auto_renewal_years”: 1

}

This boundary is critical. The Go validator should not receive a vague paragraph and be expected to infer policy facts differently on every run.

The Python component must validate:

  • Required fields
  • Data types
  • Currency normalization
  • Date and term calculations
  • Confidence or evidence references
  • Missing and conflicting values

ADK then wraps the remote service as a RemoteA2aAgent and passes the structured payload to it. Google describes this abstraction as a way to make a remote A2A-compatible service behave like a local sub-agent inside the workflow.

Why Go Performs Deterministic Validation

The Go service applies business policy through normal code.

That is the right choice when a rule should always produce the same result. A contract above an approved value cap should not pass because a language model interpreted the policy creatively.

A simplified validation function might follow this pattern:

func Validate(c Contract, p Policy) Verdict {

violations := []string{}

 

if c.ValueUSD > p.MaxValueUSD {

violations = append(violations, “value_limit”)

}

if c.TermYears > p.MaxTermYears {

violations = append(violations, “term_limit”)

}

if !c.HasExitClause {

violations = append(violations, “missing_exit_clause”)

}

if c.UnlimitedLiability {

violations = append(violations, “unlimited_liability”)

}

 

return Verdict{

Pass:       len(violations) == 0,

Violations: violations,

}

}

Google’s sample uses Go’s HTTP stack, JSON-RPC handling, an agent-card endpoint, and a deterministic policy checker. The example policy includes a $500,000 value cap, a five-year term limit, minimum insurance, exit requirements, and liability and renewal restrictions.

A2A Message Flow Example

A simplified exchange could work as follows:

  1. Python discovers Go through its agent card.
  2. Python creates an A2A task or message.
  3. The message contains normalized contract data and policy context.
  4. Go validates the request schema.
  5. Go applies deterministic rules.
  6. Go returns task status, verdict, and violation codes.
  7. Python stores the trace and generates the final report.

A conceptual request envelope might be:

{

“jsonrpc”: “2.0”,

“id”: “audit-014”,

“method”: “SendMessage”,

“params”: {

“message”: {

“role”: “user”,

“parts”: [

{

“kind”: “data”,

“data”: {

“contract”: {

“value_usd”: 425000,

“term_years”: 4,

“has_exit_clause”: true

}

}

}

]

}

}

}

The repository documents support for SendMessage, tasks/send, and tasks/get-style interactions in its Go handler. The exact wire format should follow the installed A2A SDK and specification version rather than copied tutorial payloads.


Error Handling That a Production Version Needs


The sample architecture becomes production-ready only when failure behavior is explicit.

Failure Recommended response
Agent card unavailable Retry with backoff, then mark the remote validator unavailable
Invalid discovery metadata Reject the remote endpoint and raise a configuration alert
Request schema failure Return a non-retryable validation error
Network timeout Retry only when the request is idempotent
Go service unavailable Queue the task or send it for manual review
Duplicate request Reuse the stored result through an idempotency key
Policy-version mismatch Reject the task and request the approved policy version
Extraction uncertainty Stop before compliance validation and request human review
Partial A2A task Poll with a bounded deadline or cancel the task
Unexpected verdict format Quarantine the response and preserve the trace

The workflow should distinguish a non-compliant contract from a failed compliance check. Treating both as “failed” can lead to incorrect business decisions.

A2A agent communication error handling retries timeouts and human review
Production A2A workflows need explicit retry, rejection, cancellation, and review paths.

Google’s repository includes simulation controls, session checkpoints, traces, Python and Go tests, and visible A2A payloads, making failure inspection part of the demonstration rather than hiding it behind one chat response.

Security and Privacy Considerations

An agent card is not proof that a remote service should be trusted.

A production implementation should use:

  • TLS for every connection
  • Service-to-service authentication
  • Authorization by agent capability
  • Strict JSON schema validation
  • Request-size limits
  • Timeouts and rate limits
  • Signed or allowlisted discovery metadata
  • Secrets stored outside prompts and payloads
  • Redaction of unnecessary contract text
  • Audit logs with sensitive fields masked
  • Policy-version identifiers
  • Network isolation for internal agents
  • Human review for uncertain extraction

A2A preserves agent opacity by allowing services to collaborate without exposing internal memory or tools. That reduces coupling, but it does not automatically provide authentication, data minimization, or permission design. Those controls remain deployment responsibilities.

A2A vs MCP

A2A and the Model Context Protocol solve related but different problems.

Protocol Main relationship Typical use
A2A Agent to agent Delegating a task to another independently operated agent
MCP Agent to tool, resource, or data source Giving an agent access to databases, files, APIs, or utilities

In this example, A2A connects the Python coordinator to the independently deployed Go compliance service.

MCP would be more appropriate if the Python agent simply needed to call a compliance-checking tool exposed within its own operating context. The official A2A project describes the two standards as complementary rather than interchangeable.


Benchmark Audit: What Has Google Demonstrated?


Google did not publish a performance benchmark for this tutorial.

Evaluation question Published evidence
Accuracy versus one monolithic agent Not reported
Latency overhead from A2A Not reported
Cost per contract Not reported
Throughput under production load Not reported
Error-recovery success rate Not reported
Gemini extraction accuracy Not benchmarked in the sample
Go policy correctness Testable through deterministic unit tests
Cross-language interoperability Demonstrated through runnable sample code
Independent verification No formal third-party evaluation

The release is an architecture tutorial, not evidence that two services outperform one.

Its strongest verifiable contribution is a runnable example showing discovery, remote invocation, deterministic validation, tracing, artifacts, and separate Python and Go tests.

Why This Matters

Enterprise systems are rarely written in one language.

AI teams may prefer Python. Infrastructure teams may use Go. Core business systems may use Java or .NET. A shared agent protocol can let each team preserve its own runtime and release cycle.

The deeper lesson is separation of responsibility:

  • Use an LLM where interpretation is genuinely ambiguous.
  • Convert the result into validated structured data.
  • Use deterministic code for hard business rules.
  • Communicate through a versioned interface.
  • Keep evidence and traces for human review.

That design is usually safer than asking one model to extract, reason, enforce policy, and explain the result inside a single prompt.

When Cross-Language Agents Are Worthwhile

This architecture is justified when:

  • Different teams own independently deployed services
  • Components require different languages or runtimes
  • One service must remain independently scalable
  • The remote component has agent-like task semantics
  • Long-running status and artifacts matter
  • Teams need framework-independent interoperability

A conventional API may be better when:

  • The call is a simple synchronous function
  • Both components belong to one application
  • No agent discovery or task lifecycle is required
  • Latency must be minimal
  • A typed RPC contract already solves the problem
  • Operational simplicity matters more than future interoperability

Adding A2A to a simple function call can create unnecessary deployment, discovery, observability, and security work.

Simple Explanation for Beginners

Imagine one employee reads contracts and another checks company policy.

The first employee is good at interpreting complicated language. The second follows a strict checklist.

Python and Gemini can perform the interpretation step. Go can apply the checklist. A2A acts like the standard form they use to exchange the extracted facts and return a decision.

They work together without being rewritten in the same programming language.

What Comes Next

The sample establishes a useful starting point, but production teams still need to measure:

  • Extraction accuracy
  • End-to-end latency
  • A2A overhead
  • Retry behavior
  • Cost per completed audit
  • Policy-version consistency
  • Human-review rates
  • Security failures
  • Compatibility across SDK upgrades

ADK currently supports multiple programming languages, and Google provides separate A2A quickstarts for exposing and consuming remote agents. Some A2A integrations remain marked experimental, so teams should pin SDK versions and test protocol compatibility before production deployment.


Conclusion: Google ADK A2A Tutorial


This Google ADK A2A tutorial demonstrates a practical way to connect Python and Go components without forcing both teams into one language.

Python handles document-oriented orchestration. Go provides deterministic and auditable policy enforcement. ADK coordinates the workflow, while A2A supplies discovery and remote task communication.

The architecture is valuable when services are independently owned and genuinely agent-like. It is unnecessary when a normal typed API would do the job.

Its most useful lesson is not that every service should become an AI agent. It is that AI reasoning and deterministic business logic should be separated by a strict, testable boundary.

Final Takeaways

  • Google published the cross-language tutorial on June 22, 2026.
  • Python handles intake, extraction, state, and orchestration.
  • Go applies deterministic compliance rules.
  • ADK represents the Go service as a remote sub-agent.
  • A2A supports discovery and JSON-RPC task communication.
  • The Go service does not need an LLM.
  • Structured data should cross the Python-Go boundary.
  • Retries require deadlines, idempotency, and failure classification.
  • A2A complements MCP rather than replacing it.
  • Google did not publish accuracy, cost, or latency benchmarks.
  • A normal API remains simpler for basic synchronous validation.

Suggested Read:

  • AI Agents Explained Simply  
  • Google Agent Development Kit Explained
  • MCP vs A2A Protocol
  • Gemini AI Developer Tools
  • Enterprise AI Security Guide 

FAQ: Google ADK A2A Tutorial


What is Google ADK A2A?

Google ADK is a framework for building and orchestrating agents. A2A is an open protocol that lets independently deployed agents discover and communicate with each other.

How do Python and Go AI agents communicate?

The remote Go service publishes an agent card. The Python ADK application discovers it, initializes a remote-agent abstraction, and exchanges task messages through the A2A interface.

What does the A2A protocol do?

A2A provides conventions for agent discovery, capability description, message exchange, task status, artifacts, and collaboration without requiring agents to expose their internal implementation.

Is A2A the same as MCP?

No. A2A primarily supports collaboration between agents. MCP primarily connects models or agents to tools, resources, and data systems. They can be used together.

How should A2A errors be handled?

Use bounded timeouts, retry only idempotent operations, classify transport and business failures separately, validate every payload, preserve task traces, and route unresolved cases to human review.

When should developers use cross-language agents?

Use them when independently owned services need agent discovery, delegation, long-running task status, or separate scaling. Use a normal API for straightforward synchronous functions.

 

References:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top