Configuration¶
This page is a reference for all tunable parameters. Read the subsystem pages (Agent Loop, Embedding Algebra, Context Composition, Research Engine) first to understand what each parameter controls.
Every numeric threshold lives in a single frozen configuration hierarchy at config/config.py. No module defines its own magic numbers. Runtime overrides use LETHE_* environment variables, and defaults are documented in .env.example. This design --- one file, frozen at startup, validated in __post_init__ --- makes behavior fully auditable and prevents the drift that occurs when thresholds scatter across modules.
Common tuning scenarios:
- Research stops too early --- lower
termination_psi_thresholdin SearchConfig, or raisebudget_alphato slow pressure - Context misses relevant evidence --- lower
ppr_damping(more exploration) or raiseppr_top_k(more candidates) - Agent loops too long --- lower
budget_iterationsorconvergence_term_threshold - Evidence too noisy --- raise
similar_to_creation_thresholdorsemantic_dedup_threshold
The configuration is organized into eleven sub-configs, each governing a distinct subsystem.
flowchart TB
ROOT["Config"]
NEO["Neo4jConfig<br/>graph database"]
EMB_S["EmbedServerConfig<br/>embedding model"]
LLM_S["LLMServerConfig<br/>reasoning model"]
SXNG["SearXNGConfig<br/>metasearch"]
TERM["TerminationConfig<br/>budget + convergence"]
EMB["EmbedConfig<br/>algebra thresholds"]
CTX["ContextConfig<br/>PPR + knapsack"]
THINK["ThinkingBudgetConfig<br/>adaptive reasoning"]
SEARCH["SearchConfig<br/>research engine"]
MEDIA["MediaConfig<br/>browser + STT"]
NLI["NliConfig<br/>DeBERTa NLI"]
ROOT --> NEO
ROOT --> EMB_S
ROOT --> LLM_S
ROOT --> SXNG
ROOT --> TERM
ROOT --> EMB
ROOT --> CTX
ROOT --> THINK
ROOT --> SEARCH
ROOT --> MEDIA
ROOT --> NLI
Service Connection¶
Neo4jConfig¶
| Parameter | Default | Env var | Description |
|---|---|---|---|
uri |
bolt://localhost:7687 |
LETHE_NEO4J_URI |
Bolt protocol endpoint |
user |
neo4j |
LETHE_NEO4J_USER |
Authentication username |
password |
lethe-dev |
LETHE_NEO4J_PASSWORD |
Authentication password (SecretStr) |
database |
neo4j |
--- | Neo4j database name |
EmbedServerConfig¶
| Parameter | Default | Env var | Description |
|---|---|---|---|
base_url |
http://127.0.0.1:8090 |
LETHE_EMBED_URL |
llama.cpp embedding server |
model_dimensions |
1024 |
LETHE_EMBED_MODEL_DIMENSIONS |
Output vector dimensionality |
batch_size |
16 |
LETHE_EMBED_BATCH_SIZE |
Maximum texts per embedding API call |
timeout_s |
300.0 |
LETHE_EMBED_TIMEOUT_S |
HTTP timeout per batch |
max_concurrent |
4 |
LETHE_EMBED_MAX_CONCURRENT |
Concurrent embedding request slots |
LLMServerConfig¶
| Parameter | Default | Env var | Description |
|---|---|---|---|
base_url |
http://127.0.0.1:8080 |
LETHE_LLM_URL |
llama.cpp reasoning server |
n_ctx |
49152 |
LETHE_LLM_N_CTX |
Context window (must match --ctx-size or --max-model-len) |
temperature |
0.6 |
LETHE_LLM_TEMPERATURE |
Sampling temperature |
top_k |
20 |
LETHE_LLM_TOP_K |
Top-k token candidates |
top_p |
0.95 |
LETHE_LLM_TOP_P |
Nucleus sampling threshold |
min_p |
0.0 |
LETHE_LLM_MIN_P |
Minimum token probability |
presence_penalty |
1.5 |
LETHE_LLM_PRESENCE_PENALTY |
Repetition penalty |
timeout_s |
1200.0 |
LETHE_LLM_TIMEOUT_S |
Per-completion wall-clock timeout |
max_http_retries |
2 |
--- | Retries on HTTP errors |
http_retry_base_s |
1.0 |
--- | Exponential backoff base for repair retries |
max_concurrent |
1 |
LETHE_LLM_MAX_CONCURRENT |
Concurrent prompt slots |
SearXNGConfig¶
| Parameter | Default | Env var | Description |
|---|---|---|---|
base_url |
http://127.0.0.1:8888 |
LETHE_SEARXNG_URL |
SearXNG metasearch endpoint |
timeout_s |
20.0 |
LETHE_SEARXNG_TIMEOUT_S |
HTTP timeout per query |
max_results |
200 |
LETHE_SEARXNG_MAX_RESULTS |
Results per query (server-side cap) |
max_pages |
5 |
LETHE_SEARXNG_MAX_PAGES |
SearXNG result pages to fetch per query |
engines |
"" |
LETHE_SEARXNG_ENGINES |
Engine filter (comma-separated) |
categories |
"" |
LETHE_SEARXNG_CATEGORIES |
Category filter |
time_range |
"" |
LETHE_SEARXNG_TIME_RANGE |
Temporal filter (day/week/month/year) |
language |
"" |
LETHE_SEARXNG_LANGUAGE |
Language filter (ISO 639-1) |
Budget and Termination¶
TerminationConfig¶
Controls the smooth budget pressure curve and convergence-based early stopping.
| Parameter | Default | Env var | Description |
|---|---|---|---|
budget_iterations |
50 |
LETHE_BUDGET_ITERATIONS |
Target iteration count (soft limit) |
max_tokens |
-1 |
LETHE_MAX_TOKENS |
Token budget (-1 = unlimited) |
wall_clock_timeout_s |
7200.0 |
LETHE_WALL_CLOCK_TIMEOUT_S |
Wall-clock soft pressure input; 2× OOM is last-resort safety |
budget_alpha |
4.0 |
LETHE_BUDGET_ALPHA |
Exponential curve steepness |
min_iterations_before_convergence |
5 |
LETHE_MIN_ITERS_CONVERGENCE |
Minimum iterations before early exit |
convergence_weight |
0.3 |
LETHE_CONVERGENCE_WEIGHT |
How much convergence accelerates progress |
convergence_term_threshold |
0.82 |
LETHE_CONVERGENCE_TERM_THRESHOLD |
Termination potential ψ threshold |
plateau_window |
3 |
LETHE_PLATEAU_WINDOW |
Iterations of convergence history for plateau detection |
plateau_std_threshold |
0.03 |
LETHE_PLATEAU_STD_THRESHOLD |
Std dev threshold for stability detection |
plateau_min_level |
0.60 |
LETHE_PLATEAU_MIN_LEVEL |
Minimum score for plateau level gate |
max_repair_attempts |
2 |
LETHE_MAX_REPAIR_ATTEMPTS |
JSON parse repair retries |
The budget curve \(c(t) = (e^{\alpha t} - 1)/(e^{\alpha} - 1)\) shapes pressure algebraically. With \(\alpha = 4.0\), the system operates at less than 20% pressure through the first half of its budget.
ThinkingBudgetConfig¶
| Parameter | Default | Env var | Description |
|---|---|---|---|
min_tokens |
6144 |
LETHE_THINKING_MIN_TOKENS |
Floor for thinking budget under high pressure |
max_tokens |
12288 |
LETHE_THINKING_MAX_TOKENS |
Ceiling at zero pressure |
Thinking budget is interpolated between min and max based on novelty, then reduced by budget pressure via BudgetManager.adjust_thinking_budget.
Embedding Algebra¶
EmbedConfig¶
The quantitative control plane (Embedding Algebra). The LLM never sees these values.
| Parameter | Default | Env var | Description |
|---|---|---|---|
similar_to_creation_threshold |
0.55 |
LETHE_SIMILAR_TO_THRESHOLD |
Cosine sim for cross-parent SIMILAR_TO edges |
evidence_ga_floor |
0.62 |
LETHE_EVIDENCE_GA_FLOOR |
Soft-gate midpoint for evidence strength mapping |
semantic_dedup_threshold |
0.95 |
LETHE_SEMANTIC_DEDUP_THRESHOLD |
Cosine sim for evidence dedup |
query_dedup_threshold |
0.92 |
LETHE_QUERY_DEDUP_THRESHOLD |
Cosine sim for query caching |
strength_floor |
0.30 |
LETHE_STRENGTH_FLOOR |
Lower bound of GA-to-strength map |
strength_ceil |
0.95 |
LETHE_STRENGTH_CEIL |
Upper bound of GA-to-strength map |
Context Composition¶
ContextConfig¶
| Parameter | Default | Env var | Description |
|---|---|---|---|
scoring_ga_weight |
0.5 |
LETHE_SCORING_GA_WEIGHT |
GA vs PPR blend in scoring |
ppr_damping |
0.85 |
--- | PPR damping factor |
ppr_max_iter |
100 |
--- | Maximum PPR power iterations |
ppr_tolerance |
1e-6 |
--- | PPR L1 convergence threshold |
ppr_top_k |
500 |
--- | Maximum candidates from PPR |
mig_verbatim_threshold |
0.4 |
--- | MIG score for VERBATIM vs GIST |
adagres_beta_min |
0.3 |
--- | Minimum AdaGReS redundancy penalty |
adagres_beta_max |
0.7 |
--- | Maximum AdaGReS redundancy penalty |
context_ratio |
0.55 |
LETHE_CONTEXT_RATIO |
Fraction of n_ctx for evidence |
din_framing_tokens |
150 |
--- | Token overhead for DIN markers |
Web Research Engine¶
SearchConfig¶
Controls the continuous zero-LLM web research pipeline: discover URLs via SearXNG, stream fetch+embed in a sliding window, score pages by goal alignment and novelty, and terminate via spectral convergence.
| Parameter | Default | Env var | Description |
|---|---|---|---|
max_inflight |
8 |
LETHE_SEARCH_MAX_INFLIGHT |
Concurrent fetch+embed coroutines in the sliding window |
budget_alpha |
5.0 |
LETHE_SEARCH_BUDGET_ALPHA |
Time-pressure curve steepness |
convergence_window |
12 |
LETHE_SEARCH_CONVERGENCE_WINDOW |
Pages of score history for plateau detection |
convergence_min_level |
0.35 |
LETHE_SEARCH_CONVERGENCE_MIN_LEVEL |
Plateau level-gate floor (below natural ~0.5-0.7 plateau so it can fire) |
discovery_max_pages |
6 |
LETHE_SEARCH_DISCOVERY_MAX_PAGES |
SearXNG result pages per discovery expansion query |
research_ga_relative |
0.55 |
LETHE_SEARCH_GA_RELATIVE |
Relative GA cutoff (fraction of batch max) for suggestions and pages |
domain_fail_threshold |
4 |
--- | Skip domain after this many consecutive fetch failures |
termination_psi_threshold |
0.7 |
LETHE_SEARCH_TERMINATION_PSI |
Unified termination gate (converge or exhaust) |
MediaConfig¶
| Parameter | Default | Env var | Description |
|---|---|---|---|
cdp_endpoint |
ws://cloak-1:9222 |
LETHE_CLOAKBROWSER_CDP |
Single CloakBrowser CDP endpoint (fallback) |
cdp_pool |
"" |
LETHE_CDP_POOL |
Comma-separated CDP endpoints for pool scaling |
page_timeout_ms |
90000 |
LETHE_PAGE_TIMEOUT_MS |
Page render timeout (Tor-calibrated) |
max_concurrent |
8 |
LETHE_BROWSER_MAX_CONCURRENT |
Maximum concurrent browser tabs per instance |
fallback_concurrency |
12 |
LETHE_FALLBACK_CONCURRENCY |
Maximum concurrent HTTP fallback fetches |
stt_url |
http://whisper:9095 |
LETHE_STT_URL |
whisper.cpp endpoint |
stt_timeout_s |
120.0 |
LETHE_STT_TIMEOUT_S |
Transcription timeout |
stt_language |
"" |
LETHE_STT_LANGUAGE |
Language code (empty = auto-detect) |
stt_max_duration_s |
600 |
LETHE_STT_MAX_DURATION_S |
Maximum video duration to transcribe |
NliConfig¶
| Parameter | Default | Env var | Description |
|---|---|---|---|
base_url |
http://127.0.0.1:8070 |
LETHE_NLI_URL |
DeBERTa NLI inference endpoint (comma-separated for round-robin) |
batch_size |
16 |
LETHE_NLI_BATCH_SIZE |
Premise-hypothesis pairs per batch |
timeout_s |
60.0 |
LETHE_NLI_TIMEOUT_S |
HTTP timeout per batch |
max_concurrent |
4 |
LETHE_NLI_MAX_CONCURRENT |
Concurrent NLI request slots |
Parameter Interactions¶
Parameters do not operate in isolation. Several groups interact to produce emergent behavior, and adjusting one without understanding its neighbors can produce counterintuitive results.
Termination sensitivity¶
The most common tuning scenario is adjusting how quickly or slowly the agent terminates. Three parameters jointly control this:
budget_alpha(TerminationConfig) shapes the pressure curve. Higher values delay pressure onset but create a steeper ramp near exhaustion. At \(\alpha = 4.0\) (default), pressure stays below 20% through the first half of the budget.convergence_term_threshold(TerminationConfig) is the \(\psi\) gate. At 0.82 (default), termination requires either strong convergence-plateau or heavy resource pressure (LETHE_CONVERGENCE_TERM_THRESHOLD).
These interact multiplicatively through \(\psi\): budget_alpha controls when pressure appears and convergence_term_threshold sets the exit bar. Convergence weights are module-level constants (CONVERGENCE_WEIGHTS for the agent loop, SEARCH_CONVERGENCE_WEIGHTS for research).
Context quality vs. breadth¶
Two parameter groups trade off what evidence the LLM sees each iteration:
ppr_dampingandppr_top_k(ContextConfig) control exploration scope. Lower damping (\(< 0.85\)) spreads PPR probability more widely, surfacing distant nodes. Higherppr_top_kadmits more candidates to scoring. Both increase breadth.scoring_ga_weight(ContextConfig) andadagres_beta_min/max(ContextConfig) control how candidates are scored and deduplicated. Higher GA weight favors goal-relevant content; higher \(\beta\) penalizes redundancy more aggressively. Both increase focus at the expense of breadth.
The entropy-adaptive scoring automatically mediates: when PPR produces a uniform distribution (high entropy — many equally-reachable nodes), the blend shifts toward goal alignment to compensate for PPR's lack of discrimination; when PPR concentrates on a few nodes (low entropy), PPR dominates because its signal is decisive.
Research aggressiveness¶
The research engine has its own budget and termination, independent of the agent loop:
- Research has no hard page budget — termination is driven purely by convergence algebra and time/session pressure.
max_inflight(SearchConfig) controls parallelism in the sliding window. Higher values increase throughput but waste more compute on early termination.termination_psi_threshold(SearchConfig) at 0.7 is intentionally lower than the agent loop's 0.82 --- research terminates faster because each web page is a cheap, independent sample.
The agent loop's budget_alpha and current pressure propagate to the research engine as session_pressure, which increases research's budget pressure. Late-session research terminates faster even if its own page budget is not exhausted.
Evidence quality gates¶
Three thresholds form a pipeline that filters what enters the graph:
evidence_ga_floor(EmbedConfig, 0.62) --- the soft-gate midpoint for evidence scoring. Chunks with GA well below this receive near-zero strength but are not dropped.semantic_dedup_threshold(EmbedConfig, 0.95) --- chunks semantically similar to existing evidence are skipped. Lowering this aggressively deduplicates but risks discarding complementary findings.similar_to_creation_threshold(EmbedConfig, 0.55) --- controls the density of the semantic graph. Lower values create moreSIMILAR_TOedges, giving PPR more cross-topic paths but risking clique saturation.
These three should move together. If you lower evidence_ga_floor (admitting more evidence), you may want to raise semantic_dedup_threshold to compensate for the increased volume.
Validation¶
All configuration is validated at construction time via __post_init__. Invariants include:
- Convergence weights must have exactly 3 elements summing to 1.0
- Strength floor must be less than ceiling
- Budget alpha must be non-negative
- Thinking budget min must be less than max
- If token budget is set, thinking budget max must be less than it
Invalid configurations raise ValueError at startup, not at runtime.
Not all parameters have environment variable overrides — some module-level
constants (like _STABILITY_EMA_ALPHA in embed/signals.py) require
editing code directly.