Skip to main content
AFK is configured primarily through code. Environment variables provide fallback defaults for LLM settings, memory backends, queues, and prompt directories. Runtime configuration APIs always take precedence.
All variables are optional. If unset, AFK uses the defaults listed below.

LLM defaults

These variables configure the default LLM provider and behavior. They are read by LLMSettings.from_env() at startup.
VariableDefaultDescription
AFK_LLM_PROVIDERlitellmDefault provider id (openai, litellm, anthropic_agent)
AFK_LLM_MODELgpt-5.2-miniDefault model name
AFK_EMBED_MODEL(none)Embedding model for vector operations
AFK_LLM_API_BASE_URL(none)Provider API base URL
AFK_LLM_API_KEY(none)Provider API key
AFK_LLM_TIMEOUT_S30Request timeout in seconds
AFK_LLM_STREAM_IDLE_TIMEOUT_S45Stream idle timeout in seconds
AFK_LLM_MAX_RETRIES3Retry attempts on transient failures
AFK_LLM_BACKOFF_BASE_S0.5Exponential backoff base in seconds
AFK_LLM_BACKOFF_JITTER_S0.15Random jitter added to backoff
AFK_LLM_JSON_MAX_RETRIES2Structured output repair attempts
AFK_LLM_MAX_INPUT_CHARS200000Input truncation ceiling in characters
API keys for specific providers (e.g. OPENAI_API_KEY, ANTHROPIC_API_KEY) are read by the underlying provider libraries, not by AFK directly. Set AFK_LLM_API_KEY only if you want a single key shared across providers.

Memory

Configure the persistent memory backend for thread-based conversations.
VariableDefaultDescription
AFK_MEMORY_BACKENDsqliteBackend type: inmemory, sqlite, redis, postgres
AFK_SQLITE_PATHafk_memory.sqlite3SQLite file path
AFK_REDIS_URL(none)Redis connection URL (e.g. redis://localhost:6379)
AFK_PG_DSN(none)PostgreSQL connection string
# Override in code — takes precedence over env vars
from afk.core import Runner

runner = Runner(memory_store=my_custom_store)

Queue

Configure the task queue backend for async agent execution.
VariableDefaultDescription
AFK_QUEUE_BACKENDinmemoryBackend type: inmemory, redis
AFK_QUEUE_RETRY_BACKOFF_BASE_S0.5Retry base delay in seconds
AFK_QUEUE_RETRY_BACKOFF_MAX_S30Retry max delay in seconds
AFK_QUEUE_RETRY_BACKOFF_JITTER_S0.2Random jitter added to backoff
The inmemory queue backend does not persist across restarts. Use redis for production workloads that need reliable task delivery.

Prompts

VariableDefaultDescription
AFK_AGENT_PROMPTS_DIR.agents/promptRoot directory for system prompt files
Agents resolve instruction_file paths relative to this directory. See System Prompts for details.

A2A

No default environment variables are required. Configure A2A host and authentication in code for an explicit security posture. See A2A for details.

Precedence

Configuration is resolved in this order (highest priority first):
  1. Constructor argumentsRunner(memory_store=...), Agent(model=...)
  2. RunnerConfig / LLMSettings objects — passed to constructors
  3. Environment variables — fallback defaults listed on this page
  4. Built-in defaults — hardcoded in the source

Next steps