Skip to main content
Run Laddr agents with local LLM models using Ollama. This guide covers configuration, Docker setup, and usage examples.

Configuration

Environment Variables

Add these to your .env file:

Configuration Priority

Laddr resolves Ollama configuration in this order (highest to lowest priority): For base URL:
  1. Per-agent base URL: LLM_BASE_URL_RESEARCHER=http://custom:11434
  2. Global Ollama URL: OLLAMA_BASE_URL=http://localhost:11434
  3. Default: http://localhost:11434
For models:
  1. Per-agent model: LLM_MODEL_RESEARCHER=gemma2:2b
  2. Global Ollama model: OLLAMA_MODEL=llama3.2:latest
  3. Global LLM model: LLM_MODEL=gemma2:2b
  4. Default: gemma2:2b

Docker Setup

When running Laddr in Docker containers, special network configuration is needed so containers can reach Ollama running on the host machine.

Problem: Container Network Isolation

By default, http://localhost:11434 inside a Docker container refers to the container itself, not the host machine where Ollama is running. Error you might see:

Solution: Use host.docker.internal

Docker provides a special hostname host.docker.internal that resolves to the host’s IP address.

Docker Compose Configuration

Update your docker-compose.yml:

Key Configuration Points

1. Environment Variable
Tells Laddr to connect to Ollama via the special hostname. 2. Extra Hosts Mapping
Maps the hostname to the Docker host’s gateway IP. 3. All Services Need It Apply this configuration to all services that use Ollama:
  • API server
  • Worker containers
  • Any agent services

Verification in Docker

Test Ollama connectivity from inside a container:
Expected: JSON response with generated text.

Usage Examples

Example 1: Simple Agent with Ollama

Example 2: Custom Ollama Server

Example 3: Mixed Backends

Example 4: Environment-Based Configuration


Available Models

Popular Ollama models you can use:
  • gemma2:2b - Fast, lightweight (good for simple tasks)
  • llama3.2:latest - Balanced performance and quality
  • mistral:7b - Good for writing and analysis
  • llama3.1:8b - Strong reasoning capabilities
  • qwen2.5:7b - Multilingual support
Start with smaller models (2b-7b) for faster responses. Use larger models (13b+) for complex reasoning tasks.

Troubleshooting

Connection Errors

If you see connection errors:
  1. Verify Ollama is running:
  2. Check Docker network:
  3. Verify environment variables:

Model Not Found

If a model is not found:
  1. Pull the model:
  2. List available models:

Performance Issues

If responses are slow:
  1. Use smaller models for simple tasks
  2. Increase Ollama’s context window if needed
  3. Check system resources (CPU, RAM)
  4. Consider using GPU acceleration

Next Steps