Skip to content

fix(sandbox): renew active turns on fast cadence - #6484

Merged
markokraemer merged 2 commits into
mainfrom
sandbox-active-turn-renewal
Aug 17, 2026
Merged

fix(sandbox): renew active turns on fast cadence#6484
markokraemer merged 2 commits into
mainfrom
sandbox-active-turn-renewal

Conversation

@markokraemer

Copy link
Copy Markdown
Contributor

Problem

The provider-neutral lifecycle renewal path ran only inside the five-minute project-maintenance sweep. A Daytona sandbox with a one-minute native timer renewed once and then stopped an exact active OpenCode turn before the next maintenance pass.

Change

  • Add a leader-owned active-turn renewal loop with a 20-second default cadence.
  • Clamp the cadence to 5-30 seconds.
  • Scope the fast lane to durable activeTurn and activeTurns authority.
  • Keep passive and ordinary idle rows in the five-minute maintenance lane.
  • Fence stop/restart generations so an old in-flight pass cannot create a duplicate loop.
  • Subtract pass runtime from the next delay to preserve start-to-start cadence.
  • Add the incident rule to the append-only learnings register.

Contract

  • Exact active turns renew deadline_at and the provider-native lifecycle.
  • Unknown turn state does not extend deadline_at.
  • Passive reads do not enter the fast lane.
  • Stopped sandboxes remain excluded and provider adapters refuse renewal.
  • Idle stop remains owned by the ordinary deadline reaper.

Verification

  • bun test apps/api/src/projects/active-turn-renewal.test.ts: 6 pass, 0 fail.
  • bun test --isolate --env-file=apps/api/scripts/test.env apps/api/src/projects/sandbox-reaper.test.ts: 94 pass, 0 fail.
  • bun test --isolate --env-file=apps/api/scripts/test.env apps/api/src/__tests__/unit-leader-election.test.ts: 12 pass, 0 fail.
  • Provider adapter suites: 79 pass, 0 fail across E2B, Daytona, and Platinum.
  • pnpm --filter kortix-api typecheck: exit 0.
  • pnpm test: exit 0; all core lanes passed in 27.9s.

Dev proof after merge

Run the live provider harness with one-minute native timers against Platinum and Daytona. Require active survival, exact deadline renewal, unchanged passive deadline, post-deadline idle stop, stopped-renewal refusal, and fixture cleanup.

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
suna Ignored Ignored Preview Aug 17, 2026 5:59am

Request Review

@strix-security

strix-security Bot commented Aug 17, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for 94eb480.


Reviewed by Strix
Re-run review · Configure security review settings

@markokraemer
markokraemer merged commit e9331d6 into main Aug 17, 2026
27 checks passed
@markokraemer

Copy link
Copy Markdown
Contributor Author

Post-merge provider proof is complete for merge e9331d6cca28c1f8e8aa83a2285938a19fc88a57.

  • Platinum with a 60-second native timeout: exact OpenCode turn remained active for 194.663 seconds. Idle stop occurred 21.534 seconds after deadline_at. Passive reads did not move the deadline. Renewal rejected the stopped sandbox. Final provider status: removed.
  • Daytona with a 60-second native timeout: exact OpenCode turn remained active for 199.818 seconds. Idle stop occurred 3.986 seconds after deadline_at. Passive reads did not move the deadline. Renewal rejected the stopped sandbox. Final provider status: removed.
  • E2B with a 60-second native timeout: exact OpenCode turn remained active for 192.205 seconds. Idle stop occurred 17.007 seconds after deadline_at. Passive reads did not move the deadline. Renewal rejected the stopped sandbox. Final provider status: removed.

Each run also verified terminal-token cleanup, stop-claim delivery rejection, unknown-state non-renewal, and no wake after stop.

Cleanup checks passed. The disposable sessions stopped. Sandbox rows archived. Open meters are zero. Disposable projects archived. Temporary credentials and PATs were removed or revoked.

Deploy Dev run: https://github.com/kortix-ai/suna/actions/runs/32005154169

Current health proof:

  • https://dev-api.kortix.com/v1/health serves e9331d6cca28c1f8e8aa83a2285938a19fc88a57.
  • Both Essentia API replicas serve the same SHA from image digest sha256:5e591b027139ed4ee7f97924873f750fad6a76d706c3019eeaa9c11fbb8b3fbf.
  • Essentia replica 0c4b816c3ac4 holds the scheduler lease.

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.

1 participant