Skip to content

Agent Serialization #519

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
boyangsvl opened this issue May 3, 2025 · 2 comments
Open

Agent Serialization #519

boyangsvl opened this issue May 3, 2025 · 2 comments
Labels
core Issues related to the core interface and implementation

Comments

@boyangsvl
Copy link
Collaborator

Discussed in #518

Originally posted by AndresPrez May 2, 2025
Is your feature request related to a problem? Please describe.
In our use case, we need to allow customers to configure and customize AI agents through a user interface without editing source code. Currently, the Agent Development Kit (ADK) does not support serialization of agents, which makes it difficult to persist user-created agents and reload them across sessions or environments. This leads to unnecessary complexity and technical overhead, especially in customer-facing scenarios where non-developers need to customize agent behavior.

Describe the solution you'd like
I'd like to see native support in the ADK for serializing and deserializing agents (e.g., saving their configuration/state to JSON or another format and rehydrating them later). Ideally, this would include:

A method like agent.serialize() that outputs a storable, structured representation of the agent and its components.

A corresponding Agent.deserialize(serialized_data) method to restore the agent.

Support for commonly configurable elements like goals, tools, memory, and workflow parameters.

Describe alternatives you've considered
We’ve explored storing parts of the agent configuration in a relational database—such as metadata, low-level parameters like temperature, and portions of the prompt or instructions. However, this approach becomes fragmented and difficult to scale, as it requires custom logic to reconstruct the agent from disparate fields. It also lacks a standardized way to persist the full agent definition or behavior in a way that integrates cleanly with the ADK runtime.

Additional context
Serialization is especially critical for production-grade use cases where agents are managed via UIs or APIs rather than code. This feature would greatly enhance usability and adoption in enterprise settings.

@boyangsvl boyangsvl added the core Issues related to the core interface and implementation label May 3, 2025
@AlankritVerma01
Copy link
Contributor

AlankritVerma01 commented May 3, 2025

Hi @boyangsvl and team,

I’d like to pick up....
Here’s where I’m at:

My understanding

  • We need agent.serialize() + Agent.deserialize(data) to save/load all config (name, description, tools, memory, model settings, sub‑agents) but skip runtime bits (callbacks, contexts).

What I’ve done so far

  • Scanned src/google/adk/agents/*.py, especially BaseAgent and LlmAgent, to list every field.
  • Noted Pydantic usage and existing registries (e.g. LLMRegistry) we can lean on.

High‑level plan

  1. Add a serialization mixin in base_agent.py using model_dump(include/exclude).
  2. Wire up small ToolRegistry/MemoryRegistry helpers for non‑primitive fields.
  3. Handle sub_agents recursively, omitting parent_agent then re‑linking.
  4. Tag payload with "schema_version": 1 and "agent_type".

Testing

  • Unit: round‑trip serialize→deserialize in test_base_agent.py.
  • Integration: use an existing fixture (e.g. agent_with_config) to verify behavior after reload.

Quick questions

  1. Any other agent types you want in v1?
  2. Registry vs inline logic, preference?

If you want me to explain my plan in more detail, please let me know that too...
Thanks!

@pashna
Copy link

pashna commented May 6, 2025

Subscribed, super hyped about this feature!

For reference, this is the interface autogen uses https://microsoft.github.io/autogen/stable//user-guide/agentchat-user-guide/serialize-components.html

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
core Issues related to the core interface and implementation
Projects
None yet
Development

No branches or pull requests

3 participants