androidengineers.Book a session

Errors retry and observability

Errors retry and observability

articleSelf-paced

Learning outcome

Diagnose a failed request without hiding it behind a fake result.

Explicit setup, validation failure and retry paths

Explicit setup, validation failure and retry paths.

A missing endpoint blocks Send and presents connection setup. A failed discovery request, rejected model output or unavailable agent becomes an error with Retry. Retry uses the remembered request but a fresh surface ID; it does not fetch an old template. A renderer error removes the visible failed surface and presents an error. The sample does not automatically send renderer errors back to Gemini for self-correction.

Retry uses a new response identity

fun retry() {
    if (!state.value.busy)
        lastRequest?.let {
            submit(it.copy(surfaceId = UUID.randomUUID().toString()))
        }
}

Inspect shows inbound A2UI messages and outbound events. It is useful for tracing a click to its surface and event ID. It is not a provider billing dashboard, persistent log or proof of token streaming. Avoid publishing traces that contain personal prompts. The server does not log request bodies, but requests are still sent to the configured endpoint and Gemini.

Failure drill

TriggerExpected evidenceInterpretation
Server stoppedError, no replacement event, Retry availableNetwork path failed
Unset server key then restartServer configuration errorRenderer does not supply inference
Unavailable model nameModel access/quota errorHealth presence check is insufficient
Cycle in test responseValidator rejects graphDo not render partial arbitrary content
New conversation while request runsOld result does not populate new conversationGeneration epoch protects ownership

Use local environment changes and deterministic test fixtures for failure drills; do not corrupt a shared service. Restore the valid model/key after a drill. A slow blocking request may consume provider resources after UI reset. Backend authentication, per-user limits, bounded provider response streaming and operational metrics require further production work.

Practice and checkpoint

Run two failure drills and one recovery on your own debug build. Record the exact error and whether the composer becomes usable. Distinguish a repository failure test from a live provider failure: they exercise different boundaries and should be reported separately.

Source and next steps

Back to roadmap · Practice this unit in the codelab

Files to inspect

YOUR LEARNING JOURNEY

0 of 12 available lessons completed

Progress saved in this browser. No account needed.
Errors retry and observability | A2UI on Android with PocketCommunity | Android Engineers