agora.fleet.profiles

Model + card run profiles — the primary inference-config source.

A ModelProfile is a self-contained spec for a run’s model configuration: model id, num_ctx, max_tokens, keep_alive, timeout, plus Ollama/VRAM sub-sections. Every inference parameter that previously needed an env var or was hardcoded is expressible here, so a normal AGORA_PROFILE=<name> python scripts/run_discord_bot_test.py run needs no other env vars.

Per-field env overrides remain as a secondary escape hatch — see apply_env_overrides(). The precedence is:

env override > profile value > schema default

Loaders look up profiles.yaml in this order: explicit path arg, AGORA_PROFILES_FILE env var, ./profiles.yaml at CWD, then a packaged default that reproduces today’s framework default (ollama/qwen2.5:7b-instruct with the historical knobs).

The factory built by build_llm_factory() returns an LLMProtocol adapter and is what agora.plan.harness.build_orchestrator() uses when a profile is supplied. Legacy (no-profile) callers keep working unchanged.

Finding: the profile is the MODEL-IDENTITY half of the axis-1 orthogonality — a campaign’s params layer as explicit OVERRIDES on top of it (profile = who the model is; campaign = the experiment’s conditions). F19 (“wire, don’t delete”) is the rule that such a parameter surface must actually reach the model AND be logged as the effective set: an inert config knob that silently does nothing is worse than a missing one, because it fakes provenance. The override wiring + effective-param logging live in the phased runner (scripts/run_phased.py:apply_campaign_params / format_effective_params).

Functions

apply_env_overrides(profile[, env])

Return a copy of profile with per-field env overrides applied.

build_llm_factory(profile, base_url)

Return a factory that resolves model_ref against profile.

load_profiles([path])

Load a ProfileSet from disk, or fall back to the packaged default.

resolve_base_url(profile, fallback)

The profile's Ollama endpoint override, or the injected fallback.

Classes

ModelProfile

Complete inference-config spec for one run.

OllamaProfile

Ollama-daemon-specific knobs that live with the profile.

ProfileSet

A versioned bundle of named profiles plus a default selection.

VRAMProfile

VRAM-pre-flight knobs that live with the profile.

class agora.fleet.profiles.ModelProfile[source]

Bases: BaseModel

Complete inference-config spec for one run.

Any field not set in a YAML profile falls back to the defaults encoded here. Typos in field names raise a pydantic validation error (extra='forbid') so silent no-ops are impossible.

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
description: str
model: str
num_ctx: int | None
max_tokens: int
temperature: float
seed: int | None
timeout_seconds: float
keep_alive: str
ollama: OllamaProfile
vram: VRAMProfile
class agora.fleet.profiles.OllamaProfile[source]

Bases: BaseModel

Ollama-daemon-specific knobs that live with the profile.

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

base_url: str | None
num_parallel: int
class agora.fleet.profiles.ProfileSet[source]

Bases: BaseModel

A versioned bundle of named profiles plus a default selection.

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

version: int
default: str
profiles: dict[str, ModelProfile]
select(name='')[source]

Return the named profile, or default when name is empty.

Raises AgoraError (with the available names) when the name is unknown, so a typo’d AGORA_PROFILE fails loudly rather than silently reverting to the default.

class agora.fleet.profiles.VRAMProfile[source]

Bases: BaseModel

VRAM-pre-flight knobs that live with the profile.

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

safety_margin_mib: int
agora.fleet.profiles.apply_env_overrides(profile, env=None)[source]

Return a copy of profile with per-field env overrides applied.

Pure function — no side effects, no global state. Useful for tests that want to probe override behavior with a synthetic env mapping rather than mutating os.environ.

Recognised env vars (each overrides exactly one field):

  • AGORA_LLM_MODEL → model

  • AGORA_LLM_NUM_CTX → num_ctx (""/"none"/"null"/"0" collapse to None so callers can defer to Ollama’s own default)

  • AGORA_LLM_MAX_TOKENS → max_tokens

  • AGORA_LLM_TEMPERATURE → temperature

  • AGORA_LLM_SEED → seed (""/"none"/"null"/"0" collapse to None so callers can defer to Ollama’s own default seed — mirrors num_ctx)

  • AGORA_LLM_TIMEOUT_SECONDS → timeout_seconds

  • AGORA_OLLAMA_BASE_URL → ollama.base_url

  • AGORA_OLLAMA_NUM_PARALLEL → ollama.num_parallel

  • AGORA_OLLAMA_KEEP_ALIVE → keep_alive

  • AGORA_VRAM_SAFETY_MARGIN_MIB → vram.safety_margin_mib

agora.fleet.profiles.build_llm_factory(profile, base_url)[source]

Return a factory that resolves model_ref against profile.

base_url is the resolved Ollama endpoint (profile override or the injected Settings default) — passed explicitly because profiles no longer carry a localhost default. Use resolve_base_url() to compute it.

An empty model_ref (the v2.3 plan-builder emits agents with model="" because the model can’t reliably guess a valid id, so the harness owns the runtime choice) falls back to profile.model. A non-empty model_ref (per-role override via AgentConfig.model) routes through the same per-provider knobs — same base_url, num_ctx, keep_alive, max_concurrent, timeout — so a mixed-model run inherits the profile’s tuning rather than reverting to adapter defaults.

For ollama/* (the only supported backend): passes base_url, num_ctx, max_concurrent (=``ollama.num_parallel``), keep_alive, default_max_tokens, and the sampling controls.

agora.fleet.profiles.load_profiles(path=None)[source]

Load a ProfileSet from disk, or fall back to the packaged default.

Precedence:
  1. path argument when supplied (composition roots pass Settings.profiles_file, which is sourced from AGORA_PROFILES_FILE; this library never reads the env itself)

  2. ./profiles.yaml in the current working directory

  3. Packaged default (so tests and fresh clones work with no file).

YAML parse errors and pydantic validation failures both surface as AgoraError with the offending path attached.

agora.fleet.profiles.resolve_base_url(profile, fallback)[source]

The profile’s Ollama endpoint override, or the injected fallback.

profile.ollama.base_url is an optional pin (None ⇒ inherit). The fallback is the single-source endpoint from Settings.ollama_base_url.