posit-dev / posit-dev/chatlas

feat: tool_code_execution() — provider-executed code execution

Open
#364 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triage:needs-review
Dominant language
Python
Stars
176
Forks
28
Avg merge
18h 42m
Merged PRs (30d)
16

Description

Code execution is the last provider-executed tool that is GA across all three first-class providers (Anthropic, OpenAI Responses API, Google Gemini) — the same footprint as tool_web_search(). A first-class tool_code_execution() would let the model run Python server-side for data analysis, math, and file processing with zero local sandbox setup, which is squarely in the wheelhouse of chatlas's data-science audience.

chat.register_tool(tool_code_execution())
chat.chat("Compute the eigenvalues of this matrix and plot them: ...")

Provider mapping

Provider Tool spec Notes
Anthropic {"type": "code_execution_20250825", ...} (newer dated variants exist) Server sandbox (Python 3.11, no internet). Container reusable across requests via container param. Free when combined with recent web search/fetch variants; otherwise ~1,550 free container-hours/org/month, then $0.05/hr. Docs
OpenAI (Responses) {"type": "code_interpreter", "container": {"type": "auto"}} Or an explicit container ID from /v1/containers. Billed per memory tier per 20-min session ($0.03–$1.92). Docs
Google types.Tool(code_execution=types.ToolCodeExecution()) No extra fee (standard token billing). Python only, ~30s per execution, no custom packages. Returns executable_code / code_execution_result parts. Docs

Design considerations

  • New content types (ContentToolRequestCodeExecution / ContentToolResponseCodeExecution) following the web search/fetch precedent, registered in PROVIDER_ANNOTATION_TYPES so each provider replays only its own blocks.
  • Container/session persistence across turns (Anthropic container, OpenAI container IDs) — likely: scan turn history for the most recent container ID and resend it.
  • Gemini models before Gemini 3 cannot mix built-in tools with custom function declarations in the same request.
  • Availability gaps: not supported on Amazon Bedrock; not supported on Vertex AI for Anthropic models (see the guard issue for how unsupported platforms should fail).

Design work for this is already underway locally (docs/plans draft + worktree).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the docs/plans draft and the existing web search/fetch implementation described in the issue. Trace the provider annotation and content-type precedents, then define the work needed for Anthropic, OpenAI Responses, and Google, including container persistence and unsupported platforms; done means the design is settled and all three providers have a consistent first-class tool path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.