Skip to content

abdimoallim/llm-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llm-agent

A very basic coding agent written in C. Works with any LLM provider via the llm C library.

Requirements

  • C99 compiler (GCC/Clang)
  • libcurl
  • pthreads
  • git (for submodule setup)

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 --recursive

Build:

make

Install to /usr/local/bin:

make install

Currently 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.

Usage

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 help

API keys

Keys 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.

REPL commands

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

Tools

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.

Confirm mode

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

Ignoring artifacts

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.

Supported providers

Refer to the llm library.

License

Apache v2.0 License

About

A very basic coding agent written in C

Resources

License

Stars

Watchers

Forks

Contributors