Skip to content

[Bug]: Python Code Interpreter Result drops non-standard MIME types instead of collecting them into extra #1984

Open

Description

@lemonzoey

Describe the bug

Result in the Python Code Interpreter SDK (e2b_code_interpreter/models.py) declares an extra field for data "not part of the standard types", but __init__ drops unknown keys from the kernel message via **kwargs instead of collecting them into extra. Non-standard MIME types the IPython kernel sends — e.g. application/vnd.plotly.v1+json, application/vnd.bokeh+json, application/vnd.vega.v5+json — are silently lost. The JS SDK's Result constructor already sweeps these into extra.

To reproduce

import json
from e2b_code_interpreter.models import Execution, parse_output

execution = Execution()
parse_output(execution, json.dumps({
    "type": "result",
    "is_main_result": True,
    "text": "hello",
    "application/vnd.plotly.v1+json": {"data": [{"x": [1, 2]}]},
}))

result = execution.results[0]
print(result.extra)            # None — the plotly payload is dropped
print(list(result.formats()))  # ['text'] — the custom MIME is missing
print(execution.to_json())      # extra is absent from the serialized output

For comparison, the JS SDK's Result collects the same key into extra, lists it in formats(), and includes it in toJSON().

Expected behavior

result.extra holds the non-standard MIME payload, formats() lists the custom MIME type, and Execution.to_json() preserves it — matching the JS SDK.

Actual behavior

The non-standard MIME type is dropped at construction, so extra is None, formats() omits it, and to_json() loses the data.

Environment

  • SDK: e2b-code-interpreter (Python), current main

Additional context

The extra field is documented as "Extra data that can be included. Not part of the standard types." — the intent is to retain these, but __init__ never assigns **kwargs to it. IPython display data commonly carries non-standard MIME types for interactive plots, so this loses real user data.

This is the Python side of the Result serialization surface and is separate from the open cluster: #1939/#1971 (data in toJSON), #1948 (chart in toJSON), #1826/#1893 (chart deserialization). None touch Python Result.__init__'s extra collection.

Activity

  1. devin-ai-integration commented on Oct 15, 2026

    @devin-ai-integration
    Contributor

    Triage

    • type: bug
    • priority: medium
    • complexity: small
    • affected_area: python-sdk/code-interpreter (e2b_code_interpreter/models.py Result.__init__)
    • actionable: yes
    • needs_clarification: false
    • summary: The Python Code Interpreter Result.__init__ discards unknown kernel keys passed via **kwargs instead of storing them in extra, so non-standard MIME outputs (e.g. Plotly/Bokeh/Vega JSON) are missing from extra, formats(), and Execution.to_json(), unlike the JS SDK. Assumes the fix is to bring Python in line with the JS SDK's behavior.

    Written by Devin

  2. CloudCorpRecords commented on Oct 16, 2026

    @CloudCorpRecords

    Hi, I would like to work on this. Plan: in the Python code interpreter Result model (e2b_code_interpreter/models.py), preserve non-standard MIME types instead of dropping them during Result construction, and add tests covering a non-standard MIME type end to end.

  3. CloudCorpRecords commented on Oct 16, 2026

    @CloudCorpRecords

    Withdrawing my claim: PR #1985 already implements this fix. My check missed the cross-referenced PR. Good luck landing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code InterpreterbugSomething isn't workingpythonPull requests that update Python codesdkImprovements or additions to SDKs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions