Repository navigation
fix(agent): re-clone + re-auth thin sandbox on DO-initiated turns - #123
Merged
Merged
Conversation
Webhook turns are prepped by the Worker (ensureSandboxReady) before dispatch,
but DO-initiated turns bypass that path: scheduled auto-merge/fix-ci follow-ups
(via scheduleFollowUp) and post-teardown resumes reach the FlueJaredAgent DO
with a possibly-empty container. With the 10m idle teardown, the auto-merge
quiet period (~10m) lands right when the container is gone, so git/gh would run
against an empty, unauthenticated sandbox.
Add a useAgentStart hook that ensures the thin sandbox is prepped before the
model's first turn: derive owner/repo from the entity key (agent_sessions row
keyed by the conversation id), mint a fresh installation token, and reuse
ensureSandboxReady(thinSandbox) to clone + re-auth. Idempotent and best-effort
(never throws into the turn). Webhook ('user') turns with an existing clone are
skipped; non-user deliveries force a re-prep so the ~1h GitHub token is also
refreshed for long-delayed follow-ups.
Not mirrored to container/flue (Phase 1 in-container Flue already owns the repo).
Validated live on getsentry/cli#1365: normal turn unaffected, no prep errors.
Co-authored-by: Cursor <[email protected]>
MathurAditya724
enabled auto-merge (squash)
August 5, 2026 18:47
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
jared | 02bdbf6 | Aug 05 2026, 06:47 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #122 (Phase 2 / DO-native + 10m idle teardown). Closes a correctness gap surfaced in review: DO-initiated turns can run against an empty, unauthenticated container.
On a webhook event the Worker runs
ensureSandboxReady(clone + GH auth) before dispatch. But two paths reach theFlueJaredAgentDurable Object without that prep:auto-merge/fix-ciskills call the DO'sscheduleFollowUpfor the remaining quiet period (~10 min), which now lands right when the container has been torn down by the 10m idle window.In those cases the thin container respins empty (no
/workspace/repo,ghunauthenticated) andgit/ghfail.Fix
Add a
useAgentStarthook inJared()that ensures the thin sandbox is prepped before the model's first turn:owner/repofrom the entity key (looked up inagent_sessionsby the conversation id, sincetoAgentInstanceIdis lossy).getRepoInstallationToken).ensureSandboxReady(thinSandbox)to clone + re-auth.Idempotent and best-effort (never throws into the turn). Webhook (
user) turns with an existing clone are skipped; non-userdeliveries force a re-prep so the ~1h GitHub token is also refreshed for long-delayed follow-ups. Not mirrored tocontainer/flue(Phase 1 in-container Flue already owns the repo).Test plan
parseOwnerRepo)biome+tsc+vitest(58 passing) +vite build(bundles cleanly into the DO)jared.getsentry.workers.dev, Version14cb364b) and re-validated ongetsentry/cli#1365: normal webhook turn unaffected (skills + gh/bash → correct decision), no prep errors / exceptions in logs, hook correctly no-ops on already-prepped turns.ensureSandboxReady).Made with Cursor