Skip to content

About

Google ADK for Java agent demo. Deterministic mode runs the agent loop without GCP credentials.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adk-sample-agent

A Google Agent Development Kit (ADK) for Java demo. An agent answers questions about laboratory sample storage by calling inventory tools through the real ADK Runner loop. The model backend is pluggable. Vertex AI Gemini is used when credentials are present. A deterministic scripted LLM covers runs without credentials.

This is a standalone portfolio project. It is not affiliated with any employer.

What it does

The agent is an LlmAgent with two function tools backed by an in-memory sample inventory (SampleTools):

  • lookupSample(sampleId) returns the record for one sample.
  • freezerOccupancy(location) reports capacity and occupancy for a storage location.

On each turn the model sees the full session history and decides the next step. With the Vertex backend a Gemini model on Vertex AI makes those decisions. With the deterministic backend a DeterministicLlm (a BaseLlm subclass) reads the same LlmRequest contents and emits the scripted next step: lookupSample, then freezerOccupancy, then a final answer composed from the tool results in the history. Either way the ADK Runner owns session state and dispatches the tool calls itself.

Requirements

  • JDK 21 and Maven 3.9+
  • For the Vertex backend only, GCP credentials through Application Default Credentials. GOOGLE_CLOUD_PROJECT must be set. GOOGLE_CLOUD_LOCATION is optional.

Run

Deterministic mode needs no credentials:

mvn -q compile exec:java \
  -Dexec.args="--backend deterministic --prompt 'Where is sample SMK-001 stored and how full is that location?'"

Vertex mode:

gcloud auth application-default login
GOOGLE_CLOUD_PROJECT=your-project mvn -q compile exec:java \
  -Dexec.args="--backend vertex --model gemini-2.5-flash --prompt 'Where is sample SMK-002?'"

A captured deterministic transcript is in results/agent-run.txt.

Test

mvn test

Seven tests run without credentials. SampleToolsTest covers the lookup paths and the occupancy counting that excludes depleted samples. DeterministicAgentTest drives the real Runner. It verifies that the event stream shows each tool call followed by its response and that the final answer is built from the tool output. The unknown-sample and no-sample-id paths are covered as well.

Layout

  • ModelBackend / DeterministicBackend / VertexBackend select the model.
  • DeterministicLlm is the credential-free BaseLlm implementation.
  • AgentFactory assembles the LlmAgent with tools and instruction.
  • AgentRunner wraps Runner with in-memory backing services.
  • AgentCli is the command line entry point.

About

Google ADK for Java agent demo. Deterministic mode runs the agent loop without GCP credentials.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages