Skip to content

AI Agent

import { Aside } from ‘@astrojs/starlight/components’;

The AI Agent is the core of Kodel.AI — a sandboxed process that receives tasks, uses an LLM to reason about them, and executes code in a Docker container.

task.assigned
┌─────────────────────────────┐
│ loop: │
│ llm.request → │
│ ← llm.response.done │
│ parse tool_calls │
│ execute tools │
│ step.report → │
└─────────────────────────────┘
task.complete / task.error

The agent has 6 built-in tools it can call during task execution:

ToolDescription
read_fileRead file contents from /workspace
write_fileCreate or overwrite a file
edit_fileMake targeted edits with search/replace
bashRun shell commands (tests, git, npm, etc.)
globFind files by pattern
grepSearch file contents with regex

The agent doesn’t call the LLM directly — it sends llm.request messages to the server over WebSocket. The server proxies the request to your configured LLM provider and streams chunks back as llm.response.chunk messages.

This design means:

  • The LLM API key never touches the agent container
  • You can switch LLM providers without redeploying agents
  • The server can log, rate-limit, and monitor all LLM calls

The agent’s behavior is controlled by a system prompt in packages/server/src/system-prompt.ts. You can override it per-deployment via the SYSTEM_PROMPT environment variable.

Each agent runs in an isolated Docker container with:

  • No network access by default (configurable)
  • Workspace limited to /workspace
  • Resource limits (CPU, memory) via Docker

For tasks requiring Docker-in-Docker (building images, running containers), enable the dind option in the Instance Template — this uses the Sysbox runtime for secure nested containerization.