adk-fluent · A2A Topology Reference

## Local vs Remote Agents comparison

### Local Agent — same process

.sub_agent() .agent_tool()

- Shared session state
- Shared memory service
- Zero network latency

    # Local: same process, direct call
    coordinator.sub_agent(local_agent)

### Remote Agent — A2A protocol

RemoteAgent(url=...)

- Separate session state
- HTTP/A2A transport layer
- Network latency overhead

    # Remote: separate process, A2A protocol
    RemoteAgent(name="helper", url="http://...")

## A2A Mesh Topology architecture

## State Bridging data flow

    # State bridging: explicit send/receive contract
    remote = (
        RemoteAgent(name="analyzer", url="http://analyzer:8080")
        .sends("document", "preferences")    # local → remote
        .receives("analysis", "confidence")   # remote → local
    )

## Resilience Patterns middleware

### M.a2a_retry(max=3)

Retry failed A2A calls with exponential backoff. Each attempt waits progressively longer before the next retry.

### M.a2a_circuit_breaker(threshold=5)

Stop calling a failing remote agent after N consecutive failures. Automatically resets after a cooldown period.

### M.a2a_timeout(seconds=30)

Time limit for remote agent responses. Raises a timeout error if the remote agent does not reply within the deadline.

### M.a2a_cache(ttl=300)

Cache remote responses to reduce network calls. Identical requests within the TTL window return the cached result.

## Composition Example hybrid

    from adk_fluent import Agent, RemoteAgent

    # A local agent — runs in the same process
    local_writer = (
        Agent("writer", "gemini-2.5-flash")
        .instruct("Write content based on research.")
        .isolate()
    )

    # A remote agent — communicates over A2A protocol
    remote_researcher = (
        RemoteAgent(name="researcher", url="http://research-service:8080")
        .sends("topic")
        .receives("findings")
    )

    # Coordinator mixes local + remote seamlessly
    coordinator = (
        Agent("coordinator", "gemini-2.5-flash")
        .instruct("Coordinate research and writing.")
        .sub_agent(local_writer)
        .sub_agent(remote_researcher)
        .middleware(M.a2a_retry(max=3) | M.a2a_timeout(seconds=30))
    )

## Discovery Methods connectivity

1
Direct URL
`RemoteAgent(url="http://agent-service:8080")`
2
Service Registry
`RemoteAgent.discover(registry_url="http://registry:9090")`
3
Agent Card
`RemoteAgent.from_card(card)`