fix(agent): stop handoff checkpoint uploads failing on large repos#3393
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "fix(agent): stop handoff checkpoint uplo..." | Re-trigger Greptile |
There was a problem hiding this comment.
Technically sound fix with good fallback logic and test coverage, but it's a complex change (523 lines) to critical agent handoff infrastructure — new API endpoint calls, a data-encoding detection heuristic, and a git-pack exclusion change — with zero reviews. Higher-risk changes with no reviews should get a human sign-off.
Cloud sessions that end without local handoff state packed every object reachable from HEAD (the entire repo snapshot for a fresh sandbox clone), then shipped it base64-encoded inside a JSON API body. On large repos the request exceeded API body limits and the final checkpoint was lost with a 413, so cold resumes could not restore the session's git state. - default the pack baseline to the branch's upstream tracking ref (which the apply side fetches before unpacking), falling back to the remote default branch that any fresh clone already contains, so packs only carry session-created objects - upload checkpoint artifacts via the presigned prepare/finalize direct upload flow, storing raw bytes instead of base64 text; keep the inline JSON upload as a fallback (also used when finalize does not confirm the artifact) and sniff pack/index magic bytes on download so legacy base64-at-rest artifacts still apply - cap artifact and inline upload sizes with clear warnings, and discard the checkpoint instead of publishing one whose required artifacts never reached storage
8222db1 to
74c0a84
Compare
Problem
Cloud sessions that end without local handoff state (the normal case: a sandbox stopped by SIGTERM) build their handoff git pack with no exclusion baseline, so git pack-objects packs everything reachable from HEAD, the entire repo snapshot. The pack is then shipped base64-encoded inside a JSON API body. On large repos (e.g. posthog/posthog, ~100 MB packed, ~134 MB after base64) the request exceeds API body limits and fails with 413 Payload Too Large, so the final checkpoint is lost and cold resumes cannot restore the session's branch, index, and uncommitted changes.
This was latent since checkpoints landed (#1665) and became visible once sandbox cleanup started gracefully stopping the agent server (PostHog/posthog#70086), which exercises the final-checkpoint capture on every cloud teardown.
Changes