Replies: 1 comment
-
|
Hi @VanQuy24,
Use
Persisting chat history and workflow state:
Checkpoint captures
An example of this could be for HITL: from agent_framework import FileCheckpointStorage
from agent_framework.chatkit import stream_agent_response
class MultiUserChatKitServer(ChatKitServer[dict[str, Any]]):
def __init__(self, store, workflow):
super().__init__(store=store)
self.workflow = workflow
self._user_checkpoints: dict[str, FileCheckpointStorage] = {}
async def respond(self, thread: ThreadMetadata, input_user_message: UserMessageItem | None, context: dict[str, Any]):
user_id = thread.id
# Per-user checkpoint storage (use FileCheckpointStorage for persistence)
if user_id not in self._user_checkpoints:
self._user_checkpoints[user_id] = FileCheckpointStorage(f"./checkpoints/{user_id}")
checkpoint_storage = self._user_checkpoints[user_id]
agent = self.workflow.as_agent()
# Resume from latest checkpoint if exists (handles HITL state too)
checkpoints = await checkpoint_storage.list_checkpoints()
checkpoint_id = checkpoints[-1].checkpoint_id if checkpoints else None
async for event in stream_agent_response(
agent.run_stream(messages, checkpoint_id=checkpoint_id, checkpoint_storage=checkpoint_storage),
thread_id=thread.id,
):
yield event |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am integrating Agent Framework Workflows with ChatKitServer where multiple users interact with the same WorkflowAgent instance.
My workflow uses multiple executors and also relies on HITL (ctx.request_info) at certain steps.
I need guidance on the correct approach to managing context, chat history, and workflow checkpointing per user.
Architecture
ctx.shared_stateto carry data through the workflow.ctx.request_info.Questions
1. How to isolate context between different users?
Right now, conversations from different users appear to overwrite or leak into each other, especially when workflows run concurrently.
I need a recommended approach to ensure each user gets clean and independent workflow state.
2. How to store chat history and workflow checkpoints properly?
My goal is that when a user returns later (possibly hours or days later), the system should be able to:
I want to understand the best practices for combining WorkflowAgent + ChatKitServer so that each user’s session is recoverable and isolated.
3. Where should I store context and state?
I am unsure what is the recommended place to persist:
ctx.shared_state)Should these be stored:
Any guidance or patterns from the maintainers is appreciated.
Issue I’m facing
When multiple users interact with the system at the same time:
I believe I’m missing a recommended approach for user-scoped state management when combining WorkflowAgent + ChatKitServer.
What I hope to learn
Any official guidance, sample patterns, or architectural recommendations would be extremely helpful.
Beta Was this translation helpful? Give feedback.
All reactions