Commit Graph

45 Commits

Author SHA1 Message Date
gitprov a9aa594d73 Read agent_id/agent_name from request body (LiteLLM extra params)
LiteLLM passes extra parameters as top-level JSON fields in the request
body. _extract_agent_name() now reads agent_id and agent_name from the
body first, then falls back to X-Agent-Name / X-Agent-Id headers.

Critically, both fields are stripped from the body before any upstream
call — otherwise Claude/LM Studio reject the unknown parameters.

Applied to all four route handlers: /v1/chat/completions, /v1/messages,
/api/chat, /api/generate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 19:41:12 +02:00
gitprov cd471c4c95 Add cross-protocol agent routing at /v1/chat/completions
When X-Agent-Name or X-Agent-Id is present and matches an agent_models
entry, Festinger routes the main inference request to the configured
provider — not just the memory-writing utility model.

Protocol translation:
  - Incoming OpenAI → outgoing Claude: system-message extraction,
    max_tokens defaulting, response translated back to OpenAI format
  - Incoming OpenAI → outgoing LM Studio/OpenAI: model + base_url swap
  - All responses returned as OpenAI-compatible JSON or SSE

Also adds streaming synthesis for /v1/chat/completions (OpenAI SSE)
and X-Agent-Id fallback in _agent_name_from_headers so numeric
AGENT_ID env vars work without needing AGENT_NAME.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 19:32:57 +02:00
gitprov 10d9e1e2dd 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>
2026-04-21 19:24:28 +02:00
gitprov 7210fe2066 Mirror request model for context discovery — no write_model_id needed
Festinger now extracts provider/model/api-key from every intercepted
request and passes it to the context-discover queue as a fallback_model.
_process_context_discover uses it when write_model_id is not configured,
so Agent0's current model (LM Studio, Ollama, Anthropic) is automatically
reused for utility LLM calls without any extra setup.

Priority: write_model_id (explicit override) > fallback_model (request mirror)

Also updates upstream_openai default in config.yaml to LM Studio's
local address (host.docker.internal:1234).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 19:17:51 +02:00
gitprov ccbb5b2d45 Adding sanity to the recollection decider 2026-04-21 19:09:25 +02:00
gitprov 128dd653e7 Adding llm to do this 2026-04-21 18:32:21 +02:00
gitprov 314f145740 Adding migration 2026-04-21 18:08:22 +02:00
gitprov 35df8c56f2 Fixing the newline error 2026-04-21 18:04:36 +02:00
gitprov 2656951bb9 Fixes 2026-04-21 17:52:27 +02:00
gitprov ce82678d14 Adding festinger 2026-04-20 18:31:13 +02:00
gitprov 98b115d471 Draing the queue 2026-04-20 18:22:57 +02:00
gitprov 58f903aec0 Adding updates to Festinger 2026-04-20 18:21:23 +02:00
gitprov 3fae2c62bd Adding improved saliency pipeline 2026-04-20 18:12:57 +02:00
gitprov 84b4a88ba1 Adding model edit 2026-04-20 17:57:48 +02:00
gitprov 402e10901a Imrpove cue scanner and remove false positives 2026-04-20 17:48:12 +02:00
gitprov b859aff3c5 Fixing festinger API 2026-04-20 17:25:56 +02:00
gitprov ce67d3ab1a Removing streaming as this caused errors 2026-04-20 17:19:05 +02:00
gitprov de907fd29a Adding throwing of out of funds exception 2026-04-20 16:58:39 +02:00
gitprov 8f14b86e68 Fixes on logging 2026-04-20 16:53:12 +02:00
gitprov 372d8e01d0 Updating main for error 2026-04-20 16:38:21 +02:00
gitprov 2f8880d785 View of rewrites 2026-04-20 16:16:46 +02:00
gitprov 8ff73d32ae Adding Festinger with wordnet 2026-04-19 16:16:13 +02:00
gitprov a27aa713d3 Adding gunnars memories to the github 2026-04-18 16:27:54 +02:00
gitprov 95dd1dfd63 Adding the knowledge files to git 2026-04-18 16:09:47 +02:00
gitprov 169410e3dc Adding multiple instances, one per agent 2026-04-17 21:45:05 +02:00
gitprov 6c84b0a0b5 Adding fixes 2026-04-14 21:24:40 +02:00
gitprov 98aeaac080 Adding loopback fix 2026-04-11 16:42:44 +02:00
gitprov 583ad88271 Reodering boostrap steps 2026-04-11 16:37:44 +02:00
gitprov a91bc920be Adding better waiting logic, waiting for process to be done - not lock to be released 2026-04-11 16:30:08 +02:00
gitprov 33237fef5b Adding better wait condition 2026-04-11 16:24:03 +02:00
gitprov 35d0700e54 Adding more practical bootstrap.sh behaviour does not overwrite if exists 2026-04-11 16:21:47 +02:00
gitprov a086899ea4 Adding some Agent0 auth stuff 2026-04-11 14:26:19 +02:00
gitprov 014ff8f8ed Adding wait for apt-get install 2026-04-11 14:02:18 +02:00
gitprov 723565571d Adding apt-get update 2026-04-11 14:00:24 +02:00
gitprov 3f796eb3d4 Workaroudn for the debian pip quirk 2026-04-11 13:52:12 +02:00
gitprov 8c88bf2f5f Ensuring pip 2026-04-11 13:46:48 +02:00
gitprov 95d36c6c62 Adding explicit python3 reference 2026-04-11 13:45:37 +02:00
gitprov f1555c61e5 Adding small fix to boostrap 2026-04-11 13:43:25 +02:00
gitprov 8f8491815d Adding small fix to running pip inside conatiner 2026-04-11 13:39:03 +02:00
gitprov a4b034d4b4 Removing python dependcy on host 2026-04-11 13:35:35 +02:00
gitprov 4460bee57b Adding better ordering and support for the clone behaviour 2026-04-11 13:22:26 +02:00
gitprov 881724203b Adding OS to the nice bootstrap script 2026-04-11 13:08:32 +02:00
gitprov defdc60a52 Small fixes 2026-04-11 13:06:08 +02:00
gitprov 5226ad0842 Adding prepwork for Inference Box 2026-04-11 12:59:02 +02:00
gitprov a6a7bb9af5 Initial commit 2026-04-11 00:43:18 +02:00