Skip to content

MARSOHS-2171: stream MARS Exec output over SSE - #2042

Merged
SSharma-10 merged 2 commits into
digitalocean:mainfrom
rmahato-code:hosted-agents/doctl-exec-sse-timeout
Oct 20, 2026
Merged

SSharma-10 merged 2 commits into
digitalocean:mainfrom
rmahato-code:hosted-agents/doctl-exec-sse-timeout

Conversation

@rmahato-code

@rmahato-code rmahato-code commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

JIRA MARSOHS-2171

Summary

  • Default doctl harness-runtime exec text output now consumes harness-api SSE (Accept: text/event-stream) so stdout/stderr appear as the guest produces them.
  • -o json keeps the existing buffered ExecInSandbox document for scripts.
  • Against an older API that does not speak SSE, text mode falls back to the buffered JSON body automatically (same flags / exit codes).

Depends on / pairs with the harness-api work:

Testing

Unit tests

go test ./do/ -count=1 -run 'StreamExec|ReadExec|EmitBuffered'
go test ./commands/ -count=1 -run 'AgentsExec'

Live testing done against local harness (dev/up on :8080)

# Create a session
CREATE_RESP="$(curl -sS -X POST \
  -H 'Authorization: Bearer do_dev_demo@acme.com' \
  -H 'Content-Type: application/x-yaml' \
  --data-binary $'name: doctl-exec-smoke\nagent: codex\ntemplate: coding\n' \
  http://127.0.0.1:8080/v2/agents/sessions)"
SID="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["session"]["session_id"])' <<<"$CREATE_RESP")"

# Wait until READY, then until a trivial exec returns 200
# (guest sandbox-agent must be accepting dials)

DOCTL=(./builds/doctl -u http://127.0.0.1:8080 -t 'do_dev_demo@acme.com' --http-retry-max 0)

# Streaming: expect "one", ~2s pause, then "two"
"${DOCTL[@]}" harness-runtime exec "$SID" -- sh -c 'echo one; sleep 2; echo two'

# Buffered JSON path unchanged
"${DOCTL[@]}" harness-runtime exec "$SID" -o json -- echo hi

# Guest exit code propagation
"${DOCTL[@]}" harness-runtime exec "$SID" -- sh -c 'echo failed; exit 7'; echo "exit=$?"

# Timeout (needs EX15 guest templates for clean 504 near budget;
# without rebuild may still surface ~timeout+30s / 500 on older agents)
"${DOCTL[@]}" harness-runtime exec "$SID" --timeout 3 -- sleep 120; echo "exit=$?"

# Cleanup
curl -sS -X DELETE -H 'Authorization: Bearer do_dev_demo@acme.com' \
  "http://127.0.0.1:8080/v2/agents/sessions/$SID"
Screenshot 2026-10-13 at 10 41 30 PM

Verified locally: unit tests green; streaming showed one then two two seconds apart; -o json returned a buffered document; guest exit 7 propagated. Timeout against the current local guest image still hit the pre-EX15 +30s backstop until templates are rebuilt with SANDBOX_BUILD_TEMPLATES=1 ./dev/up.

@rmahato-code rmahato-code changed the title agents: stream sandbox exec output over SSE MARSOHS-2171: stream MARS Exec output over SSE Oct 13, 2026
rmahato-code and others added 2 commits October 20, 2026 17:53
Consume harness-api's Accept: text/event-stream exec path for default
text output so long commands show progress live, while -o json keeps the
buffered document for scripts. Fall back to JSON when the server does
not speak SSE yet.

Co-authored-by: Cursor <cursoragent@cursor.com>
Map harness-api EX15 GatewayTimeout and SSE capacity 429 responses to
customer-facing titles/tips instead of generic unavailable/rate-limit copy.

Co-authored-by: Cursor <cursoragent@cursor.com>
@rmahato-code
rmahato-code force-pushed the hosted-agents/doctl-exec-sse-timeout branch from 930e57e to 9f7c846 Compare October 20, 2026 12:25
@SSharma-10
SSharma-10 merged commit ad0d6d6 into digitalocean:main Oct 20, 2026
9 checks passed
@rmahato-code
rmahato-code deleted the hosted-agents/doctl-exec-sse-timeout branch October 21, 2026 10:11
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.

2 participants