Parameters
The request body is identical to Run code. Streaming is selected with thestream=true query parameter.
Events
Each SSE frame carries one JSON object with atype field.
Streamed code output uses the field name
text, while streamed command output uses
data. They are separate endpoints with separate wire contracts.result payload carries whichever representations the value produced:
Errors
When the executed code raises, anerror frame is emitted before end:
on_error and on the returned CodeRunResponse. The CLI
prints the traceback and exits non-zero.
When to stream
Streaming and a buffered run return the same result. Stream when intermediate output matters, or when you want to stop early. Use the buffered call when you only need the final value.Endpoint
POST /v1/agents/runtime/{runtime_id}/code/run?stream=true