Urgent.News

What's breaking now, across thousands of outlets.

AI

Your Google ADK Agent Has Four Places to Put Context. Choose Carefully.

The first version of an agent usually has one place for context: the prompt. The user request goes in. Conversation history goes in. Tool results, preferences, account details, retrieved documents, and generated files follow. The agent appears to “remember” because every useful fact is repeatedly placed in front of the model. That design works until the context becomes expensive, stale, difficult…

Google's Agent Development Kit (ADK) provides four distinct storage options for context in TypeScript applications: session events, session state, long-term memory, and artifacts. While these options offer flexibility, deciding where to store information is crucial for the agent's performance and reliability. A single context bucket can create several bugs that impact the agent's functionality.

Imagine a travel agent assisting a user in comparing hotels. After receiving the user's preference for quiet rooms, the agent generates a spreadsheet with 40 hotel options. If the agent later resumes the conversation for a different trip, issues may arise due to the agent's inability to distinguish between relevant and irrelevant data.

A bug could be that the agent repeats the 40 raw hotel results in the next conversation, or the agent fails to delete stale data, leading to budgeting difficulties for the new trip. Another bug could be that the agent permanently stores the preference to "prefer quiet rooms," which should ideally be a temporary constraint shared across sessions.

To avoid such issues, ADK offers four storage options:

1. Session Events: These represent one conversation thread and provide a chronological record of user messages, agent responses, tool activity, state changes, and errors. Session events are ideal for storing information that is relevant to the current conversation, such as the user's hotel preferences.

2. Session State: This holds dynamic values that the agent needs while working on a task. State can be updated using a context object and has different lifetimes. For example, a temporary value like the number of hotels fetched could be scoped as temp:hotel_count, while a shared user preference like "prefer quiet rooms" could be stored with no prefix, making it accessible across sessions.

3. Long-Term Memory: This service allows the agent to search for useful knowledge that may come from earlier sessions or external sources. Long-term memory is useful for storing preferences that should be available across multiple conversations, such as "usually prefers hotels near public transit." However, policies must be in place to determine what knowledge is eligible for retrieval, how retrieval is scoped, and when facts expire.

4. Artifacts: These are binary files such as generated reports, images, or PDFs. Unlike chat messages, artifacts have a lifecycle and can be accessed by the agent across sessions. For example, a hotel comparison report could be stored as hotel-comparison.csv version 2, with version control ensuring cleaner data management.

The Gemini Interactions API allows for continuity by passing a previous_interaction_id, but this feature does not decide where data should be stored or how long it should be retained. The responsibility of determining context storage and retention policies still lies with the agent developer.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

15 AI Coding Prompts for Codex and Claude Code

Code audits, performance work, feature planning, and product research, with an installable workflow skill. Theo shared six ways he uses Astra : code cleanup, performance work, agent setup, PR and…

Ten fine-tuning mistakes I see students make (and made myself)

I built FineTune Studio after making most of these mistakes on my own runs. They are not exotic. They are the difference between "I fine-tuned a model" on a resume and "I fine-tuned a model and here…

  • Always start with a baseline model to compare fine-tuning results.
  • Use validated data for training, not unvalidated data, to avoid errors.
  • Define evaluation metrics and held-out sets before training to guide experimentation.

Running ML models in the browser with ONNX Runtime Web: a practical guide

FaceVision does face detection, recognition and liveness checks without sending a single frame to a server, because every model runs in the browser through ONNX Runtime Web.

  • FaceVision runs ML models in the browser without sending data to a server
  • ONNX Runtime Web facilitates model execution in the browser
  • Privacy-focused design stores only vector embeddings in FastAPI and PostgreSQL

More from Sunday 6 September →