aws-samples / aws-samples/sample-autonomous-cloud-coding-agents

RFC: Checkpoint rewind and fork for off-track tasks

Open
#564 0 comments 0 reactions 0 assignees View on GitHub
agent-runtime observability orchestration RFC-proposal
Dominant language
TypeScript
Stars
143
Forks
46
Avg merge
3d 9h
Merged PRs (30d)
20

Description

## Primary area

Cross-cutting / multiple

## Related issue or feature request

- [WORKFLOWS.md](https://github.com/aws-samples/sample-autonomous-cloud-coding-agents/blob/main/docs/design/WORKFLOWS.md) — `workflow_state.json` checkpoints
- #252 (step-aware event supersede on orchestrator replay — distinct concern)
- #484 (S3-backed SDK session store — recommended before v1)
- #560 (workflow commit trailers — git lineage)

## Summary

Expose **operator-driven rewind and fork** for workflow execution: resume a terminal or failed task from an earlier completed step without full cold-start, or branch a new task from a checkpoint to explore an alternate approach.

```bash
bgagent rewind --list
bgagent rewind --to implement
bgagent fork --to plan
```

## Use case and motivation

When an agent goes off-track late in a workflow, operators re-submit tasks or manually check out branches — losing checkpoint context and burning cold-start cost. Rewind reduces waste; fork supports A/B exploration under audit.

Distinct from #252, which fixes **duplicate progress events** when the orchestrator replays durable steps — not operator-initiated rewind to an earlier workflow step.

## Proposal

1. Extend `workflow_state.json` (and TaskRecord metadata) with ordered checkpoint entries: `step_name`, `step_kind`, `sdk_session_id`, `git_commit_sha`, artifact pointers.
2. **Rewind:** new task pinned to checkpoint; skip completed deterministic steps; re-enter agent at selected step; `rewound_from` lineage.
3. **Fork:** same without archiving source; `forked_from` lineage.
4. CLI commands + orchestrator create-task path.

## Out of scope

- Automatic rewind on verify failure (#457)
- Per-step orchestrator durable checkpoints (agent-side only per ADR-014)
- Compensation/rollback of side effects (e.g. unpublish PR)

## Potential challenges

- Session resume without #484 may restart agent at turn 0 even if steps are skipped.
- `ensure_pr` / `deliver_artifact` idempotency on re-entry.
- Admission limits for new RUNNING tasks.

---

**Note:** Non-triaged RFCs may not get timely review. PRs on non-triaged issues might not be accepted.

Contributor guide

Open the contributing guide

Research direction

Start by reading docs/design/WORKFLOWS.md and the workflow_state.json checkpoint model, then trace the CLI commands and orchestrator create-task path mentioned in the proposal. Compare the design with ADR-014 and related issues #252, #484, and #560; done would require an agreed design covering checkpoint metadata, rewind/fork lineage, session handling, idempotency, and admission limits.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, git, typescript
Domain
backend, cli, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.