Skip to content

feat(dynaflow): DynamoDB checkpointer for run/thread state (#280) - #334

Merged
codeforstartups merged 1 commit into
codeforstartups:developmentfrom
shivamm-gupta:issue-280-dynamodb-checkpointer
Oct 8, 2026
Merged

codeforstartups merged 1 commit into
codeforstartups:developmentfrom
shivamm-gupta:issue-280-dynamodb-checkpointer

Conversation

@shivamm-gupta

Copy link
Copy Markdown
Collaborator

Description

Closes #280

Implements persistent run and thread state checkpointing for agent orchestration (dynaflow pillar), enabling long-running and human-in-the-loop workflows to survive restarts and support deterministic time-travel resumption.

Changes

  1. Core Checkpointing Abstractions:

    • Introduced Checkpoint data model with thread_id, checkpoint_id, parent_checkpoint_id lineage tracking, execution step numbers, node identifiers, state dictionaries, metadata, and ISO timestamps.
    • Defined BaseCheckpointer abstract contract providing save(), get(), list(), and convenient put() operations.
  2. In-Memory Checkpointer:

    • Implemented MemoryCheckpointer with thread-safe lock management for local development, rapid unit testing, and ephemeral agent executions.
  3. DynamoDB-Backed Checkpointer:

    • Implemented DynamoDBCheckpointer aligned with dynavec's single-table schema:
      • Checkpoint records: pk = "{namespace}#checkpoint#{thread_id}#{checkpoint_id}"
      • Thread manifest records: pk = "{namespace}#thread#{thread_id}" maintaining pointers to latest checkpoint and chronological history.
    • Handles lossless conversion of complex Python objects, dictionaries, lists, and numbers using _to_dynamo and _from_dynamo.
  4. Engine and Agent Integration:

    • Wired BaseCheckpointer into ReActAgent (__init__, run, arun).
    • Automatically writes state checkpoints after each reasoning step and tool invocation.
    • Added thread resumption (resume_from or existing thread_id) restoring messages, prior steps, and tool execution counts.

Verification

  • Added 6 comprehensive tests in tests/test_checkpointer.py covering:
    • Checkpoint serialization round-trips
    • MemoryCheckpointer CRUD and time-travel lookups
    • Moto-based AWS DynamoDB table tests for save/get/list and thread isolation
    • ReActAgent step-by-step checkpointing and interrupted thread resumption
  • Verified all existing agent tests pass: pytest tests/test_agents.py tests/test_checkpointer.py (14 passed).
  • Verified clean formatting and linting via ruff check and ruff format.

@codeforstartups

Copy link
Copy Markdown
Owner

Thanks @shivamm-gupta — reviewed, and the checkpointer design (closes #280) looks great. It needs a quick rebase onto latest development before I can merge, because two PRs landed under it today:

To rebase:

git fetch upstream && git rebase upstream/development
# resolve: re-apply the checkpoint save/load around the new helper calls in run()/arun()
uv run --no-sync mypy && uv run --no-sync pytest -q
git push --force-with-lease

The react.py resolution is the real one: keep your thread_id/resume_from params and checkpoint-at-each-step behavior, but call the extracted helpers (_process_tool_calls, _finalize_result) instead of the old inline code. I didn't want to rewrite your resume semantics against a refactor you hadn't seen, hence the ask. Ping me once pushed and I'll re-review + merge promptly. 🙏

…orstartups#280)

- Add Checkpoint data model with parent lineage tracking and lossless serialization
- Define BaseCheckpointer interface with save, get, list, and put operations
- Implement MemoryCheckpointer for offline execution, debugging, and testing
- Implement DynamoDBCheckpointer keyed by thread_id and checkpoint_id with thread manifests
- Wire checkpointer into ReActAgent to record state after each step and support time-travel resumption
- Add comprehensive moto-based test suite in tests/test_checkpointer.py
@shivamm-gupta
shivamm-gupta force-pushed the issue-280-dynamodb-checkpointer branch from 3e0b7bb to ebf349f Compare October 8, 2026 03:32
@shivamm-gupta

Copy link
Copy Markdown
Collaborator Author

Rebased onto latest \upstream/development! Integrated the checkpoint save/load logic around the new _process_tool_calls\ and _finalize_result\ helpers in both
un()\ and \�run(). All unit tests and ruff lint checks passing cleanly.

@codeforstartups
codeforstartups merged commit 3a2d14a into codeforstartups:development Oct 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamoDB checkpointer for run/thread state

2 participants