Drain cloud sandbox exec streams to EOF after completion - #1615
Open
parteeksingh24 wants to merge 2 commits into
Open
Drain cloud sandbox exec streams to EOF after completion#1615parteeksingh24 wants to merge 2 commits into
cloud sandbox exec streams to EOF after completion#1615parteeksingh24 wants to merge 2 commits into
Conversation
- Replace 500ms post-completion abort with a 30s drain race - Warn on stderr when the drain times out; JSON stays clean - Bound the final stdout drain wait at 2s after a timeout - Anchor the regression test to the execution-served signal
|
The latest Agentuity deployment details.
View deployment logs with the Agentuity CLI: |
Contributor
📝 WalkthroughWalkthroughThe sandbox exec command now uses bounded stream-drain and stdout-backpressure waits, with tests covering delayed output in plain and JSON modes. ChangesSandbox execution streams
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Canary Packages Publishedversion: PackagesInstallAdd to your {
"dependencies": {
"@agentuity/client": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-client-3.1.9-5330111.tgz",
"@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-schedule-3.1.9-5330111.tgz",
"@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-coder-3.1.9-5330111.tgz",
"@agentuity/coder-tui": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-coder-tui-3.1.9-5330111.tgz",
"@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-keyvalue-3.1.9-5330111.tgz",
"@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-queue-3.1.9-5330111.tgz",
"@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-claude-code-3.1.9-5330111.tgz",
"@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-opencode-3.1.9-5330111.tgz",
"@agentuity/vite": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-vite-3.1.9-5330111.tgz",
"@agentuity/analytics": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-analytics-3.1.9-5330111.tgz",
"@agentuity/config": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-config-3.1.9-5330111.tgz",
"@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-webhook-3.1.9-5330111.tgz",
"@agentuity/skills": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-skills-3.1.9-5330111.tgz",
"@agentuity/pi": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-pi-3.1.9-5330111.tgz",
"@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-vector-3.1.9-5330111.tgz",
"@agentuity/hono": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-hono-3.1.9-5330111.tgz",
"@agentuity/stream": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-stream-3.1.9-5330111.tgz",
"@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-task-3.1.9-5330111.tgz",
"@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-migrate-3.1.9-5330111.tgz",
"@agentuity/genesis": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-genesis-3.1.9-5330111.tgz",
"@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-cli-3.1.9-5330111.tgz",
"@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-email-3.1.9-5330111.tgz",
"@agentuity/api": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-api-3.1.9-5330111.tgz",
"@agentuity/adapter": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-adapter-3.1.9-5330111.tgz",
"@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-runtime-3.1.9-5330111.tgz",
"@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-sandbox-3.1.9-5330111.tgz",
"@agentuity/aigateway": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-aigateway-3.1.9-5330111.tgz",
"create-agentuity": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/create-agentuity-3.1.9-5330111.tgz",
"@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-db-3.1.9-5330111.tgz",
"@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-postgres-3.1.9-5330111.tgz",
"@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-schema-3.1.9-5330111.tgz",
"@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-server-3.1.9-5330111.tgz",
"@agentuity/storage": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-storage-3.1.9-5330111.tgz",
"@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-core-3.1.9-5330111.tgz",
"@agentuity/telemetry": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-telemetry-3.1.9-5330111.tgz",
"@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-drizzle-3.1.9-5330111.tgz"
}
}Or install directly: bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-client-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-schedule-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-coder-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-coder-tui-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-keyvalue-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-queue-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-claude-code-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-opencode-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-vite-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-analytics-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-config-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-webhook-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-skills-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-pi-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-vector-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-hono-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-stream-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-task-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-migrate-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-genesis-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-cli-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-email-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-api-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-adapter-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-runtime-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-sandbox-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-aigateway-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/create-agentuity-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-db-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-postgres-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-schema-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-server-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-storage-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-core-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-telemetry-3.1.9-5330111.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.9-5330111/agentuity-drizzle-3.1.9-5330111.tgz |
Co-authored-by: Cursor <cursoragent@cursor.com>
jhaynie
approved these changes
Jul 13, 2026
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
STREAM_DRAIN_TIMEOUT_MS(30s) instead of aborting readers after 500ms.output may be incompletewarning to stderr (JSON stdout stays clean), aborts the readers, and observes the rejection.process.stdoutdrain wait atSTDOUT_DRAIN_GRACE_MS(2s) after a timed-out stream drain so a stuck stdout consumer cannot hold the process open.agentuity/infra. This client fix already recovers output against current production servers.Why
complete/v2finished (PR #600 reverted the #518 wait).packages/cli/src/cmd/cloud/sandbox/exec.ts).Implementation
Drain race after execution complete
When streams are still open after the execution result arrives, wait for EOF up to 30s. On timeout, warn on stderr, abort, and observe the rejected stream promise so it does not become an unhandled rejection:
Bounded stdout drain after timeout
If the stream drain timed out and stdout still needs a drain event, resolve after 2s at most:
Regression coverage
packages/cli/test/cmd/cloud/sandbox/exec.test.tsinstalls a fetch fake whose Pulse stream releases its chunk 1200ms after the execution result is served. That delay is anchored to the completion response so scheduling skew before completion cannot accidentally land inside the old 500ms window. Plain and JSON modes both expect the delayed line.How to review
packages/cli/src/cmd/cloud/sandbox/exec.ts(post-completion stream wait)streamDrainTimedOutpackages/cli/test/cmd/cloud/sandbox/exec.test.tsReferences / Sources
Verification
bun test packages/cli/test/cmd/cloud/sandbox/exec.test.ts: 2/2 pass.bunx tsc --noEmitinpackages/cli: pass.Follow-ups
packages/sandboxwriteAndDrainis not abort-aware (pre-existing). Making stream writes abort-aware is deliberately out of scope here.Summary by CodeRabbit
Bug Fixes
Tests