This example demonstrates how to build an AI coding agent using AgentKit and E2B Code Interpreter. The agent can execute code and help with programming tasks.
coding-agent-2.mp4
- Install dependencies:
npm install- Create a
.envfile in the root of the project with the following environment variables:
E2B_API_KEY=your_e2b_api_key # Get one at https://e2b.dev/docs
ANTHROPIC_API_KEY=your_anthropic_api_key # Get one at https://console.anthropic.com/settings/keys
# Optional: Specify which Claude model to use (defaults to claude-haiku-4-5)
# All models: https://console.anthropic.com/docs/en/about-claude/models/overview
ANTHROPIC_MODEL=claude-sonnet-4-5-20250929- Start the Inngest Dev Server:
npx inngest-cli@latest dev- Start the program:
npm run start- Open the Inngest Dev Server at http://127.0.0.1:8288/functions
- Trigger the Coding Agent with the following input:
{
"data": {
"input": "Create a Next.js TodoList demo and its associated unit tests. Save the contents into /tmp/todolist-demo/. Finally run the tests with coverage"
}
}- The agent will start executing the task and you will see the output in the Inngest Dev Server.
- Code execution using E2B Code Interpreter
- Built with AgentKit for robust agent capabilities
- TypeScript support
- Hot reloading during development
- Durable execution (retries on rate limits, etc) with Inngest
- Context Window Management - Handles long conversations without hitting token limits
- Smart Error Handling - Validates model names and provides helpful error messages
The project uses TypeScript and is set up with the following key dependencies:
@e2b/code-interpreter: For code execution capabilities@inngest/agent-kit: For building the AI agentzod: For runtime type checkingtypescript: For static type checking
This agent includes automatic output truncation to prevent large outputs from bloating the conversation context:
- Terminal commands: Output truncated to 15,000 characters
- File reads: Individual files limited to 20,000 characters, batch reads to 50,000 characters
- Code execution: Output truncated to 10,000 characters
Adjust limits in src/contextManager.ts:
export const CONTEXT_CONFIG = {
MAX_TERMINAL_OUTPUT: 15000,
MAX_FILE_CONTENT: 20000,
MAX_TOTAL_FILE_CONTENT: 50000,
MAX_CODE_OUTPUT: 10000,
};

