Skip to content

Python: AgentSession Pending Request Resume Failure #5818

Open

Description

@GeekeRahul

I am using AgentSession to persist and restore workflow execution state in Python. The scenario that fails is Magentic orchestration with human plan review enabled.

When the workflow pauses for human plan review, the SSE stream emits a request_id. I persist the session state, including the pending request metadata, and then try to resume the same session by sending feedback for that same request_id. The session does not resume the pending request and instead errors.

Expected behavior :

If a session pauses on request_info and I restore that same AgentSession later, responding with the same request_id should resume execution successfully.

Question :

How should pending requests in AgentSession be handled after restoring a persisted session? Specifically, if human plan review in Magentic generates a request_id and that pending request is saved in session state, what is the correct way to resume it later using the same request_id?

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)
    workflowsUsage: [Issues, PRs], Target: Workflows
    on May 13, 2026
  2. added
    bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)
    on May 26, 2026
  3. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on May 26, 2026
  4. github-actions commented on May 26, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    Repro: WorkflowAgent._pending_requests (python/packages/core/agent_framework/_workflows/_agent.py:131) is not captured by AgentSession.to_dict() (python/packages/core/agent_framework/_sessions.py:744-756). When _run_core() at line 422 checks bool(self.pending_requests) after session restore on a new agent, it finds empty dict and falls to the else branch (line 466) starting a fresh run instead of resuming. Minimal repro: create WorkflowAgent with a RequestingExecutor, run until request_info emitted, serialize session with to_dict(), create new agent, restore session with from_dict(), and attempt to send approval response for the original request_id — workflow starts fresh instead of resuming.

    • Failing test: python/packages/core/tests/workflow/test_issue_5818_session_pending_request_resume.py
    • Files examined: python/packages/core/agent_framework/_sessions.py, python/packages/core/agent_framework/_workflows/_agent.py, python/packages/core/agent_framework/_workflows/_workflow_executor.py, python/packages/core/agent_framework/_workflows/_request_info_mixin.py, python/packages/core/tests/workflow/test_workflow_agent.py, python/samples/03-workflows/orchestrations/magentic_human_plan_review.py, python/samples/03-workflows/orchestrations/magentic_checkpoint.py
    • Tests run: python/packages/core/tests/workflow/test_issue_5818_session_pending_request_resume.py
    • Current version: 1.6.0
  5. TaoChenOSU commented on May 27, 2026

    @TaoChenOSU
    Contributor

    Pending requests are persisted in checkpoints rather than sessions. Evan Mattson (@moonbox3) should we hide the workflow related abstractions such as checkpoints in workflows as agents?

  6. GeekeRahul commented on Jun 16, 2026

    @GeekeRahul
    Author

    Tao Chen (@TaoChenOSU) Hi team, following up on this issue for an update.
    Could you share current status and expected timeline for a fix?

  7. TaoChenOSU commented on Jun 24, 2026

    @TaoChenOSU
    Contributor

    @TaoChenOSU Hi team, following up on this issue for an update. Could you share current status and expected timeline for a fix?

    Hi, GeekeRahul,

    Folding the checkpoint into the agent session will likely require a bigger change and we are still evaluating it. For now, please use checkpoint instead.

  8. HarperZ9 commented on Jul 21, 2026

    @HarperZ9

    Since the current guidance is to persist and resume through the checkpoint, would a small conformance fixture around that contract be useful before the larger AgentSession design decision?

    I can contribute an offline, no-model test that records a structural receipt across pause -> persist checkpoint -> construct a fresh agent/workflow -> restore -> respond and asserts:

    • the same workflow graph signature and request_id resume exactly one pending request;
    • the pending request ID, payload digest, and ordered event types remain stable across restore;
    • replaying the same response after consumption is either rejected or has explicitly documented idempotent behavior;
    • a mismatched graph, missing request, or altered pending-request payload fails before any executor or tool invocation.

    The fixture would store only IDs, digests, checkpoint metadata, and event types—no model output or raw request payload—and it would not claim exactly-once behavior for external tool side effects. If that matches the intended checkpoint semantics, I’m happy to prepare a narrow test-only PR; otherwise I’ll leave the scope here.

  9. GeekeRahul commented on Jul 28, 2026

    @GeekeRahul
    Author

    @TaoChenOSU Hi team, following up on this issue for an update. Could you share current status and expected timeline for a fix?

    Hi, @GeekeRahul,

    Folding the checkpoint into the agent session will likely require a bigger change and we are still evaluating it. For now, please use checkpoint instead.

    Hi Tao Chen (@TaoChenOSU) , is there any update on AgentSession and do we have any planned timeline? We are currently moving forward with checkpoint approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)orchestrationUsage: [Issues, PRs], Target: multi-agent orchestration (high-level patterns)pythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowworkflowsUsage: [Issues, PRs], Target: Workflows

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions