Skip to content

feat(agents,api): route LLM tasks through gateway aliases; drop default model (#478)#491

Merged
beenuar merged 3 commits into
beenuar:mainfrom
adi-devv:feat/litellm-alias-routing
Jul 19, 2026
Merged

feat(agents,api): route LLM tasks through gateway aliases; drop default model (#478)#491
beenuar merged 3 commits into
beenuar:mainfrom
adi-devv:feat/litellm-alias-routing

Conversation

@adi-devv

Copy link
Copy Markdown
Contributor

Closes #478 — PR2 of 2 (behavioral half). Stacked on #PR1 (feat/litellm-gateway) — please review/merge PR1 first; until it merges, this PR's diff includes PR1's commit.

What this does

Every live LLM call now requests a logical task alias (aisoc-triage, aisoc-recon, aisoc-investigation, aisoc-copilot, aisoc-summary, aisoc-report, aisoc-nl) instead of a hardcoded model. The LiteLLM gateway (PR1) owns the alias → real-model mapping. The shipped gpt-4o-mini default is removed, as the issue asks.

  • New services/agents/app/llm/factory.pymake_chat_model(role) / resolve_model_alias(role) + resolve_base_url() / chat_completions_url(). No hardcoded default.
  • model_pins.py — all 7 roles pinned to aisoc-<role> aliases, each chain terminating in the deterministic floor.
  • ~14 callsites routed: agents (auto-triage, cloud/identity/insider/phishing), investigator (recon/forensic/responder/report-writer), copilot, contextual, NL translator; API endpoints (translation, hunts, knowledge base, phishing) via new services/api/app/services/model_aliases.py.

Behavior change

Live LLM now runs through the gateway (OPENAI_BASE_URL), or pin a concrete model per role via AISOC_MODEL_PIN_<ROLE> (escape hatch — the slim demo sets these so keyed demos keep working). With neither, the deterministic offline path is used. OPENAI_MODEL still applies to the separate explain/BYOK path.

Verification

  • 91 agents tests pass (new test_llm_factory.py + tightened test_litellm_config.py); pyflakes clean; all files byte-compile.
  • Live: the LiteLLM proxy recognizes and routes every aisoc-* alias the refactored code emits.
  • API-service tests weren't run locally (pre-existing missing python-jose dep in the dev env); the changed API modules import cleanly and the new model_aliases helper resolves correctly.

🤖 Generated with Claude Code

@adi-devv
adi-devv requested a review from beenuar as a code owner July 18, 2026 16:32
beenuar added a commit to adi-devv/AiSOC that referenced this pull request Jul 19, 2026
PR beenuar#491 refactored services/agents/app/nl_query/translator.py to route
the LLM-enhance path through the gateway alias (resolve_model_alias("nl")
+ chat_completions_url()) but didn't regenerate the API's vendored mirror.
`scripts/sync_vendored_nl_query.py --check` (the Python Lint & Type-check
gate) failed on the drift. Re-ran the sync so the vendored copy matches
byte-for-byte. In the API service the lazy `app.llm.factory` import is
absent and enhance_with_llm falls back to the deterministic translation
exactly as before — no behavioral change on the API side.
adi-devv and others added 3 commits July 19, 2026 08:47
…lt model (beenuar#478)

PR2 of 2 for beenuar#478. Every live LLM call now requests a logical task alias
(aisoc-triage / recon / investigation / copilot / summary / report / nl) instead
of a hardcoded model; the LiteLLM gateway (PR1) owns the alias -> real-model map.

- New services/agents/app/llm/factory.py: make_chat_model(role) +
  resolve_model_alias(role) + resolve_base_url()/chat_completions_url();
  no hardcoded default model.
- model_pins.py: all seven roles pinned to aisoc-<role> aliases, each chain
  terminating in the deterministic floor.
- Routed ~14 callsites: agents (auto-triage, cloud/identity/insider/phishing),
  investigator (recon/forensic/responder/report-writer), copilot, contextual,
  NL translator; API endpoints (translation, hunts, knowledge base, phishing)
  via new services/api/app/services/model_aliases.py. Removed the hardcoded
  gpt-4o-mini default everywhere.

Behaviour change (removes the shipped default live model, as beenuar#478 asks): live
LLM now runs through the gateway (OPENAI_BASE_URL), or pin a concrete model per
role via AISOC_MODEL_PIN_<ROLE> (escape hatch; the slim demo sets these so keyed
demos keep working). With neither, the deterministic offline path is used.

Tests: services/agents/tests/test_llm_factory.py + tightened test_litellm_config.py
(91 agents tests green; pyflakes clean). Live-verified: the gateway recognizes and
routes every alias the refactored code emits.

Closes beenuar#478.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…eenuar#478)

Fix the three I001 import-order errors the CI ruff check gate flagged
(test_litellm_config, test_llm_factory, knowledge_base). No behavioural change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
PR beenuar#491 refactored services/agents/app/nl_query/translator.py to route
the LLM-enhance path through the gateway alias (resolve_model_alias("nl")
+ chat_completions_url()) but didn't regenerate the API's vendored mirror.
`scripts/sync_vendored_nl_query.py --check` (the Python Lint & Type-check
gate) failed on the drift. Re-ran the sync so the vendored copy matches
byte-for-byte. In the API service the lazy `app.llm.factory` import is
absent and enhance_with_llm falls back to the deterministic translation
exactly as before — no behavioral change on the API side.
@beenuar
beenuar force-pushed the feat/litellm-alias-routing branch from 922602c to de9f1c6 Compare July 19, 2026 15:49
@beenuar
beenuar merged commit 460cc4f into beenuar:main Jul 19, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add LiteLLM gateway for task-based model routing and observability

2 participants