Skip to content

Python: persist pending request IDs through session serialization (fixes #5818)#6190

Open
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-5818-session-pending-requests
Open

Python: persist pending request IDs through session serialization (fixes #5818)#6190
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-5818-session-pending-requests

Conversation

@hanhan761
Copy link
Copy Markdown

Summary

When a workflow pauses for human-in-the-loop input (e.g. Magentic plan review), the pending request IDs are kept in \WorkflowAgent._pending_requests. If the session is serialized with \ o_dict()\ and later restored with \ rom_dict()\ on a new agent instance, the pending requests are lost. The agent then starts a fresh run instead of resuming the paused workflow.

Changes

Added two helper methods on \WorkflowAgent:

  • _store_pending_requests_in_session()\ — saves pending request IDs to \session.state["_pending_requests"]\ after each run
  • _restore_pending_requests_from_session()\ — restores pending request IDs from \session.state\ before each run

Both _run_impl\ and _run_stream_impl\ call these methods, so the fix covers streaming and non-streaming execution.

Since the data is stored in \session.state, the existing \ o_dict()/\ rom_dict()\ serialization handles it automatically — no changes needed to \AgentSession.

Related

Fixes #5818

Copilot AI review requested due to automatic review settings May 30, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: AgentSession Pending Request Resume Failure

2 participants