Skip to content

Python: Public API to Save and Load ChatAgent State #1698

@droideronline

Description

@droideronline

Summary

It would be great to have a public API for saving and loading the state of a ChatAgent.

Currently, this can be done through serialize and deserialize, but a dedicated public API would make it much easier and more consistent to manage agent state within complex workflows.


Use Case

In a workflow, we might have multiple ChatAgents running concurrently or sequentially. If an API error occurs during execution, we can already rely on checkpoints to resume from the last running AgentExecutor.

However, what’s missing is the ability to restore the ChatAgent’s state itself — including the conversation context, chat history, and internal thread instance — so that it can continue seamlessly from where it left off.

A save_state() / load_state() (or similar) public API would make this workflow recovery much more robust and developer-friendly.


Why This Is Useful

  • Enables fine-grained recovery inside workflows without manual serialization.
  • Makes it easy to persist conversational context between runs or sessions.
  • Simplifies handling of partial failures when multiple agents are involved.
  • Aligns with checkpoint-based resumability in AgentExecutor.

Proposed API (Example)

# Save agent state
state = chat_agent.save_state()

# Restore agent state later
chat_agent.load_state(state)

This would complement existing serialize/deserialize functionality while providing a clearer, officially supported interface for developers.

cc: @ekzhu , @moonbox3 , @victordibia

Metadata

Metadata

Assignees

Labels

pythonsquad: workflowsAgent Framework Workflows SquadworkflowsRelated to Workflows in agent-framework

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions