feat: introduce checkpoint in experimental#2181
feat: introduce checkpoint in experimental#2181JackYPCOnline merged 2 commits intostrands-agents:mainfrom
Conversation
|
Adding checkpoint to |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Issue: Per AGENTS.md: "After making changes that affect the directory structure (adding new directories, moving files, or adding significant new files), you MUST update this directory structure section to reflect the current state of the repository." The new Suggestion: Add a |
|
Issue: This PR introduces a new public dataclass ( Suggestion: Add the |
|
Assessment: Comment Clean, well-scoped PR that introduces types and tests only — good separation of concerns across the PR 1/2 series. The Review Categories
Good use of the experimental module for iterating on the API before promotion. |
|
Assessment: Comment All prior review feedback has been addressed — terminology is consistent ("agent loop"), the Snapshot/Checkpoint relationship is documented, AGENTS.md is updated, and the error message is improved. One remaining item on exception type consistency. Details
Clean iteration — the code is well-structured and ready for the behavioral PR to build on. |
Description
Replaces the experimental checkpoint module with a redesigned
Checkpointdataclass and adds"checkpoint"to theStopReasontype. This is PR 1 of 2 — types and tests only, no behavioral changes.What changed
Checkpointdataclass (experimental/checkpoint/checkpoint.py): Schema-versioned withto_dict()/from_dict()serialization,CheckpointPositionliteral ("after_model"|"after_tools"), andapp_datadict for provider-owned metadata (e.g. Temporal workflow IDs).from_dict()rejects schema version mismatches and logs a warning on unknown keys for debuggability."checkpoint"added toStopReason(types/event_loop.py): Type-level addition only — nothing emits this value yet.experimental/checkpoint/__init__.py: exportsCheckpoint,CHECKPOINT_SCHEMA_VERSION, andCheckpointPosition.What this PR does NOT change
Agent,AgentResult,EventLoopStopEvent, orevent_loop.pybehavior."checkpoint"stop reason yet.Follow-up PR (PR 2 of 2) will include
checkpointing=Trueflag onAgentconstructorafter_modelandafter_toolscycle boundariescheckpointResumecontent block for resuming from a checkpointcheckpointfield onAgentResultand extendedEventLoopStopEventtupleCheckpointpromoted to top-levelstrandsexportRelated Issues
Documentation PR
Type of Change
New feature
Testing
6 unit tests with 100% coverage on
checkpoint.py: round-trip serialization, schema version immutability, schema mismatch rejection, defaults, unknown field warning, missing version rejection.I ran
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.