<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/build-an-llm-agent-that-can-write-and-run-code-fkiupwm0t" -->

---
title: Build an LLM Agent That Can Write and Run Code | daily.dev
description: A hands-on walkthrough for building a code-executing LLM agent using the OpenAI Agents SDK and Docker. Covers the three core components: the model, workspace,...
canonical: https://daily.dev/posts/build-an-llm-agent-that-can-write-and-run-code-fkiupwm0t
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Build an LLM Agent That Can Write and Run Code | daily.dev
og:description: A hands-on walkthrough for building a code-executing LLM agent using the OpenAI Agents SDK and Docker. Covers the three core components: the model, workspace,...
og:url: https://daily.dev/posts/build-an-llm-agent-that-can-write-and-run-code-fkiupwm0t
og:image: https://api.daily.dev/og/posts/fKIUpWM0T.png
og:image:alt: Build an LLM Agent That Can Write and Run Code
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Build an LLM Agent That Can Write and Run Code

**[Towards Data Science](https://daily.dev/sources/tds)** · 10 min read · 1 upvotes · 0 comments

## Summary

A hands-on walkthrough for building a code-executing LLM agent using the OpenAI Agents SDK and Docker. Covers the three core components: the model, workspace, and execution environment. Includes a practical case study where a SandboxAgent analyzes a CSV file for energy anomalies, writes Python code inside a Docker container, and returns charts and a markdown report. Also discusses the CodeInterpreterTool and ShellTool alternatives, and summarizes key design decisions around instructions, file staging, runtime dependencies, and output file naming.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://towardsdatascience.com/build-an-llm-agent-that-can-write-and-run-code>

## Questions this post answers

### How do I set up a SandboxAgent with the OpenAI Agents SDK to write and run code in Docker?

Create a Manifest specifying which local files to stage into the workspace, instantiate a SandboxAgent with a model, instructions, and the manifest, then create a DockerSandboxClient pointing to a custom Docker image via DockerSandboxClientOptions. Apply the manifest to the sandbox session, then run the agent with Runner.run using a RunConfig that references the sandbox session.

_Building agentic workflows around Docker sandboxes is easier when daily.dev surfaces related SDK examples as you build._

### What Python libraries should I install in a Docker image for an LLM agent that does data analysis?

A minimal setup installs numpy, scipy, pandas, and matplotlib on a python:3.12-slim base image, plus setting MPLBACKEND=Agg so matplotlib can save figures without a display in a non-interactive container. This combination is sufficient for tasks like inspecting CSV files, computing statistics, and generating charts inside the sandbox.

_daily.dev helps developers comparing sandbox runtime setups for agent workflows stay current on new approaches._

### What is the difference between SandboxAgent, CodeInterpreterTool, and ShellTool in the OpenAI Agents SDK?

SandboxAgent runs code in a self-managed environment like Docker and includes shell access by default as part of its sandbox capabilities. CodeInterpreterTool attaches to a regular agent and runs code in an OpenAI-managed environment, useful when you don't want to manage Docker images and local runtimes yourself. ShellTool provides shell execution for command-line oriented workflows.

_Choosing between managed and self-hosted agent execution options is simpler with daily.dev tracking SDK updates._

## Similar posts on daily.dev

- [You Should Write An Agent](https://daily.dev/posts/you-should-write-an-agent-krwovyz8f) · Fly.io · 2 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#ai-agents](https://daily.dev/tags/ai-agents), [#docker](https://daily.dev/tags/docker)

[View this post on daily.dev](https://daily.dev/posts/build-an-llm-agent-that-can-write-and-run-code-fkiupwm0t)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Build an LLM Agent That Can Write and Run Code","url":"https://daily.dev/posts/build-an-llm-agent-that-can-write-and-run-code-fkiupwm0t","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/build-an-llm-agent-that-can-write-and-run-code-fkiupwm0t"},"datePublished":"2026-07-22T13:36:37.617Z","dateModified":"2026-09-14T08:29:39.336Z","description":"A hands-on walkthrough for building a code-executing LLM agent using the OpenAI Agents SDK and Docker. Covers the three core components: the model, workspace,...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/04cf0b7a2933b1fecdb1f1e128e870f1?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/04cf0b7a2933b1fecdb1f1e128e870f1?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Towards Data Science","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Towards Data Science","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/tds","url":"https://daily.dev/sources/tds"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/build-an-llm-agent-that-can-write-and-run-code-fkiupwm0t","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,ai-agents,docker","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Towards Data Science","item":"https://daily.dev/sources/tds"},{"@type":"ListItem","position":3,"name":"Build an LLM Agent That Can Write and Run Code"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/build-an-llm-agent-that-can-write-and-run-code-fkiupwm0t#faq","mainEntity":[{"@type":"Question","name":"How do I set up a SandboxAgent with the OpenAI Agents SDK to write and run code in Docker?","acceptedAnswer":{"@type":"Answer","text":"Create a Manifest specifying which local files to stage into the workspace, instantiate a SandboxAgent with a model, instructions, and the manifest, then create a DockerSandboxClient pointing to a custom Docker image via DockerSandboxClientOptions. Apply the manifest to the sandbox session, then run the agent with Runner.run using a RunConfig that references the sandbox session. Building agentic workflows around Docker sandboxes is easier when daily.dev surfaces related SDK examples as you build."}},{"@type":"Question","name":"What Python libraries should I install in a Docker image for an LLM agent that does data analysis?","acceptedAnswer":{"@type":"Answer","text":"A minimal setup installs numpy, scipy, pandas, and matplotlib on a python:3.12-slim base image, plus setting MPLBACKEND=Agg so matplotlib can save figures without a display in a non-interactive container. This combination is sufficient for tasks like inspecting CSV files, computing statistics, and generating charts inside the sandbox. daily.dev helps developers comparing sandbox runtime setups for agent workflows stay current on new approaches."}},{"@type":"Question","name":"What is the difference between SandboxAgent, CodeInterpreterTool, and ShellTool in the OpenAI Agents SDK?","acceptedAnswer":{"@type":"Answer","text":"SandboxAgent runs code in a self-managed environment like Docker and includes shell access by default as part of its sandbox capabilities. CodeInterpreterTool attaches to a regular agent and runs code in an OpenAI-managed environment, useful when you don't want to manage Docker images and local runtimes yourself. ShellTool provides shell execution for command-line oriented workflows. Choosing between managed and self-hosted agent execution options is simpler with daily.dev tracking SDK updates."}}]}
```

