jypi
  • Explore
ChatWays to LearnMind mapAbout

jypi

  • About Us
  • Our Mission
  • Team
  • Careers

Resources

  • Ways to Learn
  • Mind map
  • Blog
  • Help Center
  • Community Guidelines
  • Contributor Guide

Legal

  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Content Policy

Connect

  • Twitter
  • Discord
  • Instagram
  • Contact Us
jypi

© 2026 jypi. All rights reserved.

Building Stateful and Personalised Agents with ADK
Chapters

1Course Introduction and ADK Overview

Course goals and roadmapWhat is ADK?Stateful vs stateless agentsPersonalisation: definitions and benefits

2Foundations: Agent Concepts, State, and Memory

3ADK Architecture and Core Components

4Designing Memory Schemas and State Models

Courses/Building Stateful and Personalised Agents with ADK/Course Introduction and ADK Overview

Course Introduction and ADK Overview

3 views

Introduce course objectives, the ADK ecosystem, terminology, and the roles engineers and product teams play when building stateful, personalised agents.

Content

3 of 4

Stateful vs stateless agents

Stateful vs Stateless Agents Explained for ADK Builders
3 views
beginner
humorous
ADK
stateful-vs-stateless
agents
gpt-5-mini
3 views

Versions:

Stateful vs Stateless Agents Explained for ADK Builders

Watch & Learn

AI-discovered learning video

YouTube

Start learning for free

Sign up to save progress, unlock study materials, and track your learning.

  • Bookmark content and pick up later
  • AI-generated study materials
  • Flashcards, timelines, and more
  • Progress tracking and certificates

Free to join · No credit card required

Stateful vs Stateless Agents — The Difference That Changes Everything

"Is my agent remembering too much, or not remembering enough?" — The question that keeps product managers up at night.

You're already familiar with ADK from the previous module (we covered "What is ADK?" and the course roadmap). Now we zoom in on a core architectural decision you'll make again and again: stateful vs stateless agents. This choice shapes personalization, scaling, privacy, and how human your agent feels.


Quick primer (no repeats — building on what you know)

We won't rehash ADK basics, but keep this in mind: ADK gives you primitives for agent orchestration, model calls, and memory connectors. The big question now is how you use those primitives to store and reuse information over time.


What does "state" mean in an agent?

  • State = any information the agent keeps between interactions that affects future behavior.
  • Examples: user preferences, conversation history, inferred user goals, authentication tokens, or a to-do list the agent is managing.

Two extremes

  • Stateless agent: Treats each request as independent — no memory of previous interactions.
  • Stateful agent: Keeps and updates information across interactions — can personalize, continue a task, or recall facts.

Why this matters for ADK-based projects

  • Personalization: Want the agent to remember that Sara prefers short answers? You need state.
  • Complex tasks: Multi-step flows (book a trip, manage a bank transfer) usually need state to track progress.
  • Scaling & cost: Stateless systems are simpler and cheaper per request. Stateful systems add storage, indexing, and retrieval costs.
  • Privacy & compliance: Storing user data introduces regulatory risk; stateless may reduce attack surface.

"Choosing between stateful and stateless is choosing what kind of relationship you want between your user and the agent: casual encounter or long-term friendship."


Real-world analogies (because metaphors hit neurons)

  • Stateless = a barista who only knows your order if you tell them each time.
  • Stateful = the barista who remembers you like oat milk and the time you asked for a quiet table.

Both are useful. The coffee shop that remembers allergies is great — until it leaks your whole coffee history to a marketing firm.


Patterns of statefulness in ADK (practical categorizations)

  1. Session-state
    • Short-lived, tied to a conversation session. Good for chat flows and form-filling.
    • Storage options: in-memory in the runtime, short TTL cache, or ADK session store.
  2. Long-term memory
    • Persistent user profile, preferences, historical facts. Used for personalization across days/weeks.
    • Storage options: databases, vector stores for embeddings, user profile tables.
  3. Ephemeral/transient state
    • Useful for single multi-step tasks (e.g., checkout). Cleared after completion.
  4. Derived state
    • Inferred attributes (e.g., "user prefers async communication"). Stored after validation.

Stateless vs Stateful: Side-by-side comparison

Aspect Stateless Stateful
Complexity Low High
Scalability High (easy to scale horizontally) Lower (requires coordinated storage)
Personalization Poor Excellent
Cost Low per request Higher (storage + retrieval)
Privacy risk Lower Higher
Latency Lower (no retrieval step) Higher (need lookup + context prep)

When to prefer stateless (short checklist)

  • You're building simple Q&A or utility endpoints.
  • Each request has a complete context (e.g., forms, explicit fields).
  • You need maximal throughput and minimal infra complexity.
  • You want to minimize long-term data retention for privacy reasons.

When to prefer stateful

  • You need continuity: multi-step tasks, conversational context, or personalization.
  • You want the agent to reduce friction by remembering preferences or past actions.
  • You're building an assistant that must behave like an ongoing collaborator.

Implementation approaches (high-level ADK-friendly examples)

Stateless handler (pseudocode)

handleRequest(request):
  // request contains all context (user message, form fields, auth)
  response = callModel(request.content)
  return response

No memory reads/writes, minimal orchestration.

Stateful handler (pseudocode with ADK memory primitives)

handleRequest(request):
  user_state = memory.read(user_id=request.userId)
  context = stitch(request.content, user_state.recent_messages)
  model_output = callModel(context)
  updated_state = updateState(user_state, model_output)
  memory.write(user_id=request.userId, updated_state)
  return model_output

Notes: "memory" could be an ADK memory connector talking to Redis, a SQL DB, or a vector store for embeddings.


Common pitfalls and practical tips

  • Too much memory: Dumping entire chat logs into the prompt causes high token costs. Use summarization or selective retrieval.
  • No memory hygiene: Old or contradictory facts confuse the model. Implement pruning and consistency checks.
  • Privacy neglect: Always store PII with consent, encryption, and retention policies.
  • Synchronous bottlenecks: Avoid blocking UX while long retrievals or costly re-rankings run. Use async updates or cached summaries.

Practical techniques: chunking + embedding + similarity search for long-term memory; session caches for short-term state; compact summaries to control token budgets.


Decision flow: Quick guide to choose

  1. Does the agent need to remember past interactions to accomplish tasks? Yes → stateful. No → stateless.
  2. Is personalization optional but valuable? Consider hybrid: session state + minimal long-term profile.
  3. Are privacy/regulatory constraints strict? Lean stateless or encrypted, consented stateful storage.

Hybrid approaches — best of both worlds

Often the right answer is hybrid:

  • Keep core conversational flow stateless for speed.
  • Store a small, curated user profile (preferences, IDs) in stateful storage.
  • Use on-demand retrieval of long-term memory only when confidence or similarity thresholds are met.

This is where ADK shines: it lets you wire memory connectors, summarizers, and retrieval layers into the call graph so you can experiment with hybrids rapidly.


Closing: Key takeaways

  • Stateful = memory, personalization, and complexity. Stateless = simplicity, scale, and fewer privacy headaches.
  • Use session state for short flows, long-term memory for personalization, and ephemeral state for single tasks.
  • Prefer hybrid strategies: small persistent profiles + selective retrievals to balance cost, UX, and privacy.

"Think of state as the agent's diary. If you want a trustworthy assistant, write useful things in the diary — but lock it up and decide how long to keep each entry."


Next steps in the course

We'll apply these ideas in the lab: wiring ADK memory connectors, building a small stateful assistant, and then refactoring it into a stateless version to compare costs and UX. Bring your curiosity and your worst data-leak nightmares — we’ll handle both.

Flashcards
Mind Map
Speed Challenge

Comments (0)

Please sign in to leave a comment.

No comments yet. Be the first to comment!

Ready to practice?

Sign up now to study with flashcards, practice questions, and more — and track your progress on this topic.

Study with flashcards, timelines, and more
Earn certificates for completed courses
Bookmark content for later reference
Track your progress across all topics