convez.ai
AgenteAutomaçãoAvançado
yukihamada

cagent — Agent de Código em C Minimalista

yukihamada/cagent

Coding agent local, sem framework, em C puro com mlx-lm/Qwen/Nemotron

Ver no GitHub
InicialPluginScore · de 0 a 100

Agent de codificação que roda integralmente em LLMs locais (~430 linhas de C puro), sem cloud ou API keys. Implementa um loop de chamar LLM → executar tool calls → retornar resultados, com 4 ferramentas básicas (bash, read/write/edit de arquivos) e aprovação manual antes de operações destrutivas.

Instalação

$npx convez-ai yukihamada/cagent

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
28%
Último commit
há 3 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Automação de tarefas de codificação em ambientes sem acesso à internet
  • Desenvolvimento e prototipagem de scripts com LLMs locais de forma autônoma
  • Avaliação e benchmarking de capacidades de reasoning em modelos locais

Veredito

Projeto de referência sólido para quem quer entender agents do zero sem abstrações. Código limpo, bem documentado e testado em eval harness. Útil principalmente para builders que dominam C e querem agentes totalmente offline; o trade-off é menor robustez comparado a frameworks.

README

A tradução para o português deste README ainda está na fila.

cagent — a Claude Code-like coding agent in ~430 lines of C

A minimal coding agent that runs entirely on a local LLM. No cloud, no API key, no framework — just libcurl, vendored cJSON, and one C file.

Works with any OpenAI-compatible /v1/chat/completions server (tested with mlx-lm serving Qwen3.6-35B-A3B and Nemotron-Cascade-2-30B on Apple Silicon).

What it does

The whole trick of a coding agent is one loop:

call LLM → got tool_calls? → run them → send results back → repeat
                └─ no → print final answer

cagent implements that loop with 4 tools — bash, read_file, write_file, edit_file — and asks permission ([y/N]) before anything destructive. That's enough to write files, compile programs, fix its own JSON mistakes, and even design a building (we made it model the Barcelona Pavilion on bim.house via MCP-over-curl, self-judged in a loop).

Build & run

make                       # cc -O2 -Wall -Wextra -o agent agent.c cJSON.c -lcurl

./agent                    # interactive REPL
./agent -y -p "task..."    # one-shot, auto-approved (for scripts/evals)
./eval.sh                  # 7-task eval harness (PASS/FAIL + timing)
flag / envdefaultmeaning
-b / AGENT_BASEhttp://127.0.0.1:8780OpenAI-compatible server
-m / AGENT_MODELmlx-community/Qwen3.6-35B-A3B-4bitmodel id
-p—one-shot prompt (exit after)
-yoffauto-approve tool calls
-t / AGENT_THINKoffthinking mode — the model reasons before acting (~5-10x tokens, much better judgment)

For a remote LLM host: ssh -L 8780:127.0.0.1:8780 user@llm-host, then run as usual.

Hard-won notes (read if you build your own)

  • mlx-lm ≥ 0.31 parses <tool_call> server-side. A prompt-only text protocol gets swallowed — the response comes back with an empty message. You MUST pass tools in the request and read message.tool_calls.
  • Never truncate UTF-8 mid-sequence. Tool output is capped (64KB); cutting a multibyte char in half produces invalid JSON that crashes mlx_lm.server's request handler. utf8_trim() backs off to a boundary.
  • finish_reason: "length" needs recovery. A model that hits max_tokens mid-tool-call has done nothing; tell it explicitly to continue in smaller chunks or it will happily claim success.
  • Qwen3.6 on mlx needs chat_template_kwargs: {enable_thinking: false}.
  • Trim old tool results from history (keep the recent tail verbatim) or long sessions eat the context window.
  • Local-LLM agents fail differently than frontier ones: they loop on the same verification command, invent API schemas, and mangle JSON-RPC plumbing. Give them pre-verified schemas and split big writes into ≤100-line chunks.
  • Thinking mode is worth the tokens for judging. The same file scored 100/100/100/100/100 by a non-thinking judge scored 90/75/70/65/95 with thinking on — and the thinking judge found a real functional bug (a <script> running before its target element existed) that two non-thinking judges had missed.

Files

filewhat
agent.cthe agent (~430 lines)
cJSON.c/.hvendored JSON library
eval.sh7-task eval harness in a sandbox
site/self-introduction sites the agent built about itself, self-judged to (near) 100/100

License

MIT

Ver o original no GitHub

Bom para

Relacionados