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.
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.
- JDK 21 and Maven 3.9+
- For the Vertex backend only, GCP credentials through Application Default
Credentials.
GOOGLE_CLOUD_PROJECTmust be set.GOOGLE_CLOUD_LOCATIONis optional.
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.
mvn testSeven 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.
ModelBackend/DeterministicBackend/VertexBackendselect the model.DeterministicLlmis the credential-freeBaseLlmimplementation.AgentFactoryassembles theLlmAgentwith tools and instruction.AgentRunnerwrapsRunnerwith in-memory backing services.AgentCliis the command line entry point.