Skip to main content

Module runtime

Module runtime 

Source
Expand description

SDK-facing typed mirror of the engine’s Runtime* events.

These five variants describe the lifecycle of a runtime block — Akribes’s first-class construct for running AI-generated code inside a sandboxed container (Python, Bash, Node, Rust, Java). They flow alongside the wrapping task’s TaskStart / TaskEnd so reducers that group by task continue to work.

Wire shape uses the engine’s standard tagged envelope {"type": "<Variant>", "payload": {...}} — same as TaskStart, TaskEnd, ToolCallStart. See crates/akribes-core/src/event.rs for the source-of-truth EngineEvent enum.

{"type": "RuntimeStart",  "payload": {"task_name": "t", "runtime_name": "run_py", "language": "python"}}
{"type": "RuntimeStdout", "payload": {"task_name": "t", "chunk": "hello\n"}}
{"type": "RuntimeStderr", "payload": {"task_name": "t", "chunk": "warn\n"}}
{"type": "RuntimeEnd",    "payload": {"task_name": "t", "exit_code": 0, "duration_ms": 1234}}
{"type": "RuntimeError",  "payload": {"task_name": "t", "kind": "Timeout", "message": "..."}}

RuntimeError.kind is a free-form string mirroring the engine’s RuntimeError enum names (NotConfigured, Timeout, SandboxUnavailable, OomKilled, Cancelled, Internal). Consumers that want a typed match should use RuntimeErrorKind::from_wire.

Structs§

RuntimeEndPayload
RuntimeEnd — emitted exactly once when the runtime invocation finished successfully (the executor returned an ExecResult). exit_code == 0 is the conventional success signal but the engine surfaces non-zero codes here too — only true infrastructure failures (timeout, OOM, sandbox unreachable) emit RuntimeErrorPayload instead.
RuntimeErrorPayload
RuntimeError — emitted instead of RuntimeEnd when the runtime invocation could not complete (timeout, OOM, sandbox unavailable, configuration missing, …). kind is a stable string tag mirroring the engine’s RuntimeError enum; message is human-readable.
RuntimeStartPayload
RuntimeStart — emitted once when the engine dispatches a runtime block to the executor. Carries the wrapping task’s name, the runtime block’s declared name, and the language tag.
RuntimeStderrPayload
RuntimeStderr — one chunk of stderr from the running container.
RuntimeStdoutPayload
RuntimeStdout — one chunk of stdout from the running container. Many of these may fire per invocation; consumers should accumulate.

Enums§

RuntimeErrorKind
Typed mirror of the engine’s RuntimeError enum for the kind field on RuntimeErrorPayload. Use RuntimeErrorKind::from_wire to dispatch; unknown strings surface as RuntimeErrorKind::Unknown so the SDK stays forward-compatible.
RuntimeEvent
Tagged-envelope decoder for the five Runtime* events. Matches the engine’s #[serde(tag = "type", content = "payload")] shape so a raw JSON envelope decodes cleanly. The SDK uses this for the JSON-bypass path in crate::events::WorkflowEvent::from_envelope_json.