Run Google ADK (adk-go) agents durably on
Temporal using the googleadk
contrib integration. The agent's orchestration loop runs inside a Workflow; each
model call runs as a Temporal Activity (via googleadk.NewModel), and tools can be
ordinary Temporal activities exposed to the agent with googleadk.ActivityAsTool
— so model calls and tools are retried, timed-out, and visible in the Temporal UI,
and the whole run is replayable.
Agents are built the native ADK way (llmagent.New + runner.New); the only
Temporal-specific pieces are googleadk.NewModel(...) as the agent's model,
googleadk.NewContext(ctx) passed to Run, and the worker-side
googleadk.NewPlugin(...) in worker.Options.Plugins, whose config holds the
real Gemini client (so the API key stays worker-side, never crossing into the
workflow). The tests register the integration's Activities directly with
googleadk.NewActivities(...) instead, since the test environments run no
plugins.
Every sample runs against a scripted FakeModel in its *_test.go, so
go test ./googleadk/... needs no API key or network.
- Basic agent — the root files in this directory
(
workflow.go,worker/,starter/): a single agent that answers a question, calling aget_weathertool implemented as a Temporal activity viagoogleadk.ActivityAsTool. - multiagent/ — a
coordinatorroot agent that delegates toweatherandjokesspecialist SubAgents via ADK's in-workflowtransfer_to_agent. - humanintheloop/ — an agent with a sensitive
delete_resourcetool whose workflow durably waits on a Temporal signal for a human's approval before the tool runs. - chat/ — a long-lived, signal-driven conversation on one ADK session that continues-as-new (exporting/importing the session) to keep history bounded.
- A running Temporal server
(e.g.
temporal server start-dev). - A Gemini API key from https://aistudio.google.com/apikey, exported worker-side:
export GEMINI_API_KEY=...
-
Start a Temporal server (see prerequisites).
-
In a second terminal, start the worker (blocks until Ctrl+C):
export GEMINI_API_KEY=...
go run googleadk/worker/main.go- In a third terminal, run the starter:
go run googleadk/starter/main.goThe starter asks "What's the weather in San Francisco?"; the agent calls the
get_weather tool and answers. You should see a final log line similar to:
2025/12/22 15:07:25 Agent answer: It's currently sunny and about 72°F in San Francisco.The exact wording comes from the model and will vary. In the Temporal UI you will
see the run's googleadk.InvokeModel and get_weather Activities.
Each scenario subdirectory has its own README with run and test instructions.
workflow_test.go (and each scenario's *_test.go) drives the workflow through a
scripted FakeModel from the googleadk contrib package, so it needs no API key
or network:
go test ./googleadk/...