Skip to content

Python: [Bug]: Resuming from a checkpoint discards caller-supplied run kwargs, contrary to the documented contract #9850

Description

@BlueX888

Observed Behavior

Resuming a workflow from a checkpoint silently discards run kwargs supplied by the caller on that continuation, contrary to the documented contract.

_workflows/_workflow.py:627-636 stages and commits the run kwargs before initial_executor_fn(); _workflows/_runner.py:334-335 then does state.clear(); state.import_state(checkpoint.state), which restores the previous run's kwargs over them. The contract comment at _workflow.py:596-601 says the prior run's kwargs are preserved "unless the caller explicitly provides new kwargs", and cancel_pending_requests shows the intended order by restoring first (_workflow.py:1553-1561).

Real output from the reproduction below:

run 1 outputs: ["message=turn-1 kwargs={'function_invocation_kwargs': {'__global__': {'key': 'OLD'}}}"]
entry checkpoint iteration: 0 state kwargs: {'function_invocation_kwargs': {'__global__': {'key': 'OLD'}}}
run 2 outputs: ["message=turn-1 kwargs={'function_invocation_kwargs': {'__global__': {'key': 'OLD'}}}"]
EXPECTED run 2 kwargs key == NEW (caller-provided kwargs win on continuation)

The discarded kwargs are also re-persisted into later checkpoints, so the continuation permanently runs with the old value.

Expected Behavior

On run(checkpoint_id=..., function_invocation_kwargs={...}) (and the same for client_kwargs, and for checkpoint_id + responses), the caller-supplied kwargs should win over the checkpoint-restored ones, as the contract comment states. Executors reading WORKFLOW_RUN_KWARGS_KEY should see NEW.

Steps to Reproduce

  1. Build a workflow with checkpoint storage whose executor records WORKFLOW_RUN_KWARGS_KEY from state.
  2. Run 1 with function_invocation_kwargs={"key": "OLD"} and save the entry checkpoint id.
  3. Rebuild the workflow on a fresh instance and call run(checkpoint_id=<entry>, function_invocation_kwargs={"key": "NEW"}).
  4. Observe the executor sees OLD, and later checkpoints keep OLD.

Minimal Reproduction

The full runnable script is repro_kwargs_restore.py (pure Python, mock executor, in-memory checkpoint storage): it prints run 1's kwargs, the entry checkpoint state, and run 2's kwargs with the expected NEW. Happy to attach it to the issue.

Error Messages and Stack Traces

No exception. Actual output:

run 2 outputs: ["message=turn-1 kwargs={'function_invocation_kwargs': {'__global__': {'key': 'OLD'}}}"]

Package Versions

agent-framework-core: 1.23.0 (main at 85f3fc6, 2026-10-29)

Python Version

Python 3.12.2

Operating System

Windows

Regression

Unknown

Additional Context

AI assistance disclosure: analysis and the reproduction script were prepared with AI assistance (Claude); I personally ran the reproduction and verified the output above.

Acknowledgements: I searched existing issues and did not find a duplicate; I personally verified this behavior; I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 29, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Oct 29, 2026
  3. github-actions commented on Oct 29, 2026

    @github-actions
    Contributor

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

    Agent analysis

    Repro: python/packages/core/agent_framework/_workflows/_workflow.py::_run_workflow_with_tracing commits caller kwargs before _runner.py::restore_from_checkpoint clears state and imports checkpoint values, triggered by run(checkpoint_id=..., function_invocation_kwargs=...) or client_kwargs, with or without responses. Minimal repro: checkpoint a request with key=OLD, rebuild the workflow, resume with key=NEW, and assert the resumed executor receives NEW; it receives OLD.

    • Failing test: python/packages/core/tests/workflow/test_workflow_kwargs.py::test_caller_kwargs_override_checkpoint_kwargs_on_restore
    • Files examined: python/packages/core/agent_framework/_workflows/_workflow.py, python/packages/core/agent_framework/_workflows/_runner.py, python/packages/core/tests/workflow/test_workflow_kwargs.py, python/packages/core/pyproject.toml
    • Tests run: test_caller_kwargs_override_checkpoint_kwargs_on_restore, test_collision_free_kwargs_survive_file_checkpoint_restore
    • Reported version: 1.23.0
    • Current version: 1.23.0
  4. added
    workflowsUsage: [Issues, PRs], Target: Workflows
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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