API Reference
formatCodeExecutionResult
function formatCodeExecutionResult(result): string;Defined in: tools/builtin/code-execution.ts:78
Fold a CodeExecutionResult into the single text result the loop hands to the model.
Parameters
| Parameter | Type | Description |
|---|---|---|
result | CodeExecutionResult | The stdout/stderr/exit code captured by a CodeExecutionBackend. |
Returns
string
A text block: stdout, an annotated stderr section when present, and an always-present exit verdict.
Remarks
Every result ends with an explicit verdict — [exit 0: ok] on success or
[exit N: error] on failure — so a code run is never a contentless result:
"ran but printed nothing" reads as a clear success rather than an ambiguous
empty string. A non-zero exit is NOT a tool error (the code ran); it is
surfaced so the model can react. This deliberately diverges from
formatShellResult, which hides a zero exit and falls back to
"(no output)" — code execution always states its outcome.