Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Evincere/klisk/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The CodeInterpreter class provides code execution capabilities for agents. This builtin tool is only supported with OpenAI models and allows agents to write and execute Python code in a sandboxed environment.

Class Definition

from klisk.core.builtin_tools import CodeInterpreter
Defined in: src/klisk/core/builtin_tools.py:17

Parameters

container
dict[str, Any] | None
default:"None"
Optional container configuration for the code interpreter environment. When None, default container settings are used.

Usage

Basic Usage (String Shortcut)

from klisk import define_agent

agent = define_agent(
    model="gpt-4o",
    builtin_tools=["code_interpreter"],
)

Object Form with Custom Configuration

from klisk import define_agent
from klisk.core.builtin_tools import CodeInterpreter

agent = define_agent(
    model="gpt-4o",
    builtin_tools=[
        CodeInterpreter(container={
            "image": "python:3.11",
            "env": {"CUSTOM_VAR": "value"}
        })
    ],
)

Default Configuration

from klisk import define_agent
from klisk.core.builtin_tools import CodeInterpreter

agent = define_agent(
    model="gpt-4o",
    builtin_tools=[
        CodeInterpreter()  # Uses default container settings
    ],
)

Multiple Builtin Tools

from klisk import define_agent
from klisk.core.builtin_tools import CodeInterpreter

agent = define_agent(
    model="gpt-4o",
    builtin_tools=[
        "web_search",
        CodeInterpreter(),
    ],
)

Important Notes

The CodeInterpreter tool is only supported with OpenAI models. Using it with non-OpenAI models will raise a ValueError.
When using the string shortcut "code_interpreter", the default configuration with container=None is used.

Build docs developers (and LLMs) love