A very basic coding agent written in C. Works with any LLM provider via the llm C library.
- C99 compiler (GCC/Clang)
- libcurl
- pthreads
- git (for submodule setup)
Clone the repo and add the llm library as a submodule:
git clone https://github.com/<username>/llm-agent
cd llm-agent
git submodule add https://github.com/abdimoallim/llm vendor/llm
git submodule update --init --recursiveBuild:
makeInstall to /usr/local/bin:
make installCurrently tested on openai/gpt-oss-20b served from Groq, there may be a few inconsistencies with JSON metadata with other providers. Refer to the preview for a working example.
llm-agent [options]
-p <provider> provider name (anthropic, openai, groq, ollama, deepseek, ...)
-m <model> model name override
-k <key> api key (falls back to env vars)
-w <path> workspace directory (defaults to cwd)
-n <name> workspace display name
-c start with confirm mode enabled
-s show token stats after each response
-h show helpKeys are read from environment variables if -k is not passed:
| Provider | Variable |
|---|---|
| Anthropic | ANTHROPIC_API_KEY |
| OpenAI | OPENAI_API_KEY |
| Groq | GROQ_API_KEY |
| Together | TOGETHER_API_KEY |
| Mistral | MISTRAL_API_KEY |
| DeepSeek | DEEPSEEK_API_KEY |
| Gemini | GEMINI_API_KEY |
| OpenRouter | OPENROUTER_API_KEY |
| (fallback) | LLM_API_KEY |
You can also set LLM_PROVIDER and LLM_MODEL env vars to avoid passing flags every time.
| Command | Description |
|---|---|
/c |
Clear conversation history |
/confirm |
Toggle confirm mode (prompts before writes/shell) |
/stats |
Toggle per-turn token usage display |
/workspace |
Show current workspace path and name |
/help |
Show command list |
/q |
Quit |
Core: read, read_range, write, apply_patch, glob, grep
Execution: bash, run_tests, build, lint
Project: tree, stat
Version control: git_status, git_diff, git_commit
Utility: summarize_file, format_code
We use apply_patch over write for existing files to minimize token usage and read_range when only specific lines are needed.
When confirm mode is active (-c or /confirm), the agent prompts before:
- Writing or patching files
- Running shell commands (
bash,build,run_tests,lint) - Creating git commits
- Formatting files
On startup the agent loads .gitignore from the workspace root and adds it to an internal ignore list. The defaults also include node_modules, __pycache__, .git, common build artifacts and binary extensions. All file-scanning tools (glob, grep, tree) respect these patterns.
Refer to the llm library.
Apache v2.0 License