Commit Graph
25 Commits
Author SHA1 Message Date
gitprovandClaude Sonnet 4.6 c8e8067993 Serialize local model calls and skip concurrent context discovery
LM Studio and Ollama run one model on one GPU — concurrent requests
cause crashes. Two fixes:

1. Per-upstream semaphore (concurrency=1) in _route_agent_chat for
   lm-studio/ollama providers. All agent-routed calls to the same
   base URL queue instead of hitting the GPU simultaneously.

2. skip_discovery=True when routing to a local model. Context discovery
   would fire a second LM Studio call alongside the main inference.
   Novel words are still registered in SOAS (low saliency) but the
   LLM confirmation step waits. Configure write_model_id or a separate
   agent model pointing at a cloud/remote model to re-enable live
   context discovery.

3. _LLM_CONCURRENCY 2 → 1 in write_queue for the same reason.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 22:07:37 +02:00
gitprovandClaude Sonnet 4.6 8aaa205dba Handle LiteLLM path variants for chat completions
Two fixes:
1. Add /chat/completions alias (no /v1 prefix) — LiteLLM custom_openai
   and openai_like providers post here directly.
2. Passthrough now redirects any path ending in chat/completions to the
   proper /v1/chat/completions handler instead of forwarding blindly.
   This catches v1/messages/chat/completions and other wrong paths that
   result from misconfigured api_base in Agent0.

Both routes get full agent routing, recollection injection, and loop
detection — they're not raw passthroughs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 19:49:17 +02:00
gitprovandClaude Sonnet 4.6 7ed61b4823 Fix double /v1 path when routing to LM Studio
call_openai() (httpx-based) appends /v1/chat/completions to the upstream
URL. But base_url in the models table typically ends in /v1 (matching the
OpenAI SDK convention used by the resolution job). Combining them produced
/v1/v1/chat/completions → 404 from LM Studio.

Strip a trailing /v1 from the stored base_url before passing it to
call_openai() in the agent routing path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 19:45:46 +02:00
gitprovandClaude Sonnet 4.6 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
gitprovandClaude Sonnet 4.6 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
gitprovandClaude Sonnet 4.6 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
gitprovandClaude Sonnet 4.6 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