llama.cpp integration

llama.cpp is a lightweight, CPU-first inference engine for LLMs using GGUF format models. RavenClaws supports llama.cpp via the generic openai-compatible provider — no special configuration needed.

Quick start

1. Start llama.cpp server

shell
# Download a GGUF model
wget https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.3-GGUF/resolve/main/mistral-7b-instruct-v0.3.Q4_K_M.gguf

# Start the server
llama-server -m mistral-7b-instruct-v0.3.Q4_K_M.gguf --port 8080

Or using Docker:

shell
docker run --rm -p 8080:8080 \
  -v $(pwd)/models:/models \
  ghcr.io/ggerganov/llama.cpp:server \
  -m /models/mistral-7b-instruct-v0.3.Q4_K_M.gguf \
  --port 8080

2. Configure RavenClaws

Via environment variables:

shell
export RAVENCLAWS__LLM__PROVIDER="openai-compatible"
export RAVENCLAWS__LLM__ENDPOINT="http://localhost:8080/v1/chat/completions"
export RAVENCLAWS__LLM__MODEL="mistral-7b-instruct-v0.3"

ravenclaws --exec "What is the capital of France?"

Configuration reference

FieldValueDescription
provideropenai-compatibleMust be set to openai-compatible
endpointhttp://localhost:8080/v1/chat/completionsllama.cpp's OpenAI-compatible endpoint
model(model name)The GGUF model loaded in llama.cpp
api_key(optional)Not needed for local llama.cpp

Tool-calling support

BackendTool callingNotes
llama.cpp❌ NoneGGUF format does not support structured tool calling
RavenClaws fallback✅ Text-based parsingDetects TOOL_CALL: / ARGS: patterns automatically

llama.cpp does not support structured function calling (OpenAI tools format). However, RavenClaws's agent loop includes a text-based fallback that detects TOOL_CALL: and ARGS: patterns in the model's response text. For best results, use --no-final-required:

shell
ravenclaws --provider openai-compatible \
  --endpoint http://localhost:8080/v1/chat/completions \
  --model mistral-7b-instruct-v0.3 \
  --exec "List the files in the current directory" \
  --no-final-required

Troubleshooting

ProblemLikely causeSolution
Connection refusedllama.cpp not runningStart llama-server with your GGUF model
Model not foundWrong model nameCheck curl http://localhost:8080/v1/models
Empty responseModel not fully loadedWait for llama.cpp to finish loading
Slow inferenceCPU-only inferenceUse a smaller quantized model (Q4_K_M or Q3_K_S)
Tool calls not workingGGUF doesn't support toolsUse --no-final-required and rely on text-based fallback
High memory usageLarge model on CPUUse a smaller GGUF quantization (Q4_K_M is a good balance)

Performance tips

  • Use quantized models — Q4_K_M offers the best quality-to-speed ratio
  • Match context window — Set --ctx-size to match your task needs (4096+ recommended for agent tasks)
  • Batch size — Increase --batch-size for faster prompt processing
  • GPU offloading — Use -ngl N to offload N layers to GPU if available

Multi-model with llama.cpp

You can use llama.cpp alongside other providers in multi-model mode:

ravenclaws.toml
[llm]
provider = "multi"

[[llm.models]]
provider = "openai-compatible"
endpoint = "http://localhost:8080/v1/chat/completions"
model = "mistral-7b-instruct-v0.3"

[[llm.models]]
provider = "openai"
model = "gpt-4o"
api_key = "${OPENAI_API_KEY}"