Add per-agent model assignments (agent_models table)

Festinger now reads X-Agent-Name from every intercepted request and
resolves the utility LLM model in priority order:
  1. agent_models table  — agent-specific (e.g. gunnar → claude, rind → qwen)
  2. write_model_id config — global default
  3. Request mirror       — same provider/model Agent0 is currently using

New API: GET/PUT/DELETE /agent-models
New admin UI: "Agent models" section with assignment form and table.

Agent0 side: add a custom header X-Agent-Name: <name> in the LLM
provider config per agent container (AGENT_NAME env var can drive this).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 19:24:28 +02:00
parent 7210fe2066
commit 10d9e1e2dd
4 changed files with 271 additions and 30 deletions
+11
View File
@@ -111,3 +111,14 @@ CREATE TABLE IF NOT EXISTS kg_write_log (
CREATE INDEX IF NOT EXISTS kwl_created_idx ON kg_write_log (created_at DESC);
CREATE INDEX IF NOT EXISTS kwl_concept_idx ON kg_write_log (concept_id);
CREATE INDEX IF NOT EXISTS kwl_op_idx ON kg_write_log (op);
-- ---------------------------------------------------------------------------
-- agent_models — per-agent LLM model assignments
-- Maps an agent identity (from X-Agent-Name header) to a specific model.
-- Priority over write_model_id (global default) when agent_name is present.
-- ---------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS agent_models (
agent_name TEXT PRIMARY KEY, -- normalised lowercase, e.g. 'gunnar', 'rind'
model_id INT NOT NULL REFERENCES models(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);