Context providers inject dynamic runtime data as system messages into the LLM context on every call. Unlike tools (which the model calls on demand), providers run automatically before every LLM request.
public_url)On every LLM call, Agent._collect_context_injections(profile) runs all active providers and returns their output as role="system" messages. These are inserted right after the memory summary, before conversation history.
Which providers run for a given call:
global_provider = True (always, regardless of profile)context_providers config field| Name | global | Description |
|---|---|---|
public_url |
yes | Injects PUBLIC_URL from settings so Navi always knows her own address |
Drop a .py file in context_providers/ at project root. Call reload_tools to activate.
name = "my_provider"
description = "What this injects."
global_provider = False # True = all profiles, False = opt-in per profile
async def get_context() -> str | None:
return "[System] ..." # or None to skip
See context_providers/_template.py for a copy-paste starting point.
Add provider names to context_providers in config.json to opt in to non-global providers:
{
"context_providers": ["hostname", "active_project"]
}
Default is an empty list — only global providers run.
reload_tools reloads both user tools and user context providers in one call. Built-in providers (in navi/context_providers/) are loaded at startup only.
Use tool_manual("write_context_provider") for the full format reference and examples before writing a provider file.
| Path | Purpose |
|---|---|
navi/context_providers/ |
Built-in providers (server code) |
context_providers/ |
User-written providers (hot-reloadable) |
context_providers/_template.py |
Format reference (not loaded) |
manuals/write_context_provider.md |
Navi's how-to guide |