ExecuteCodeResult

The result of an ExecuteCode call, returned as the terminal structuredContent of the response stream.

JSON representation
{
  "executionId": string,
  "session": string,
  "executionCount": integer,
  "stdout": string,
  "stderr": string,
  "result": string,
  "executionError": {
    object (ExecuteCodeResult.Error)
  },
  "outputTruncated": boolean,
  "richOutputsDropped": boolean,
  "richOutputs": [
    {
      object (ExecuteCodeResult.RichOutput)
    }
  ]
}
Fields
executionId

string

The execution identifier this result is for, echoed from the request. Empty when the request supplied no executionId (such an execution is not resumable). Use it to resume.

session

string

The session the execution ran in. Format: runtimes/{runtime}/sessions/{session}.

executionCount

integer

The Jupyter In[N] execution count assigned by the kernel. Informational only. Not for addressing executions, for that use executionId.

stdout

string

Aggregated stdout across the execution.

stderr

string

Aggregated stderr across the execution.

result

string

The text/plain representation of the last expression's value, if the execution ended on an expression. Empty otherwise.

executionError

object (ExecuteCodeResult.Error)

Populated when the execution raised. Mutually exclusive with a successful completion.

outputTruncated

boolean

Whether the runtime truncated buffered output (size or line caps hit). When true, stdout/stderr are tail-truncated.

richOutputsDropped
(deprecated)

boolean

Deprecated: use richOutputs. This tool never inlines rich output bytes, so this is true whenever the execution produced any rich (non-text) output (e.g. images, Plotly/Vega figures, widgets) and false for text-only executions. When rich-output capture is enabled, that same set is reported structurally in richOutputs, so a non-empty richOutputs is the equivalent signal. Still populated for backward compatibility.

richOutputs[]

object (ExecuteCodeResult.RichOutput)

The rich (non-text) outputs captured for this execution, one entry per rich output in emission order, reported from the runtime's actual write ledger (the capture preamble records what it wrote, including drops) rather than reconstructed from a naming convention. Each entry carries its MIME representations and whether it was written (with a reason when not).

ExecuteCodeResult.Error

A Python exception raised during execution.

JSON representation
{
  "name": string,
  "value": string,
  "traceback": [
    string
  ]
}
Fields
name

string

The exception class name, e.g. "NameError".

value

string

The exception message, e.g. "name 'foo' is not defined".

traceback[]

string

The formatted traceback, one frame per entry.

ExecuteCodeResult.RichOutput

A single rich (non-text) output the runtime captured for this execution.

JSON representation
{
  "index": integer,
  "mimeTypes": [
    string
  ],
  "sizeBytes": string,

  // Union field output_result can be only one of the following:
  "filePath": string,
  "errorInfo": {
    object (ErrorInfo)
  }
  // End of list of possible types for union field output_result.
}
Fields
index

integer

0-based index of this output among the execution's rich outputs, in emission order. Dense and monotonic: a dropped output still occupies its index, so later indices never shift. This is the stable identifier for a dropped output, which has no filePath.

mimeTypes[]

string

The rich MIME representations this output carries, in the kernel's emission order, e.g. ["image/png", "text/html"]. These are alternative renderings of the SAME output; a client picks the one it can render and reads it from the bundle at filePath (i.e. data[mime]). Excludes the always-present "text/plain" fallback (still present in the bundle) and Colab's internal intrinsic type. Non-empty even for a dropped output (whose bundle was never written), so a client can tell what was lost.

sizeBytes

string (int64 format)

Size in bytes of the nbformat bundle file at filePath as written on the runtime's disk. This is the base64-inflated on-disk bundle size (i.e. how many bytes a fetch transfers), NOT the decoded asset size. A hint so a client can decide whether to fetch. Set only for a written output; 0 (omitted) for a dropped one.

Union field output_result. Whether this output was written (file_path) or dropped (error_info). output_result can be only one of the following:
filePath

string

Absolute /content/... path to the nbformat bundle written on the runtime's filesystem, e.g. /content/.dsm_outputs/{execution_msg_id}/out-000.json. Set iff the output was written. Keys only, never bytes; the bytes can be fetched from the live runtime out of band.

errorInfo

object (ErrorInfo)

Why the output was not written, set iff it was dropped.