Skip to content

feature(agent): add base_url for the detect and analyze chat agents#245

Closed
nghiadaulau wants to merge 1 commit into
VersusControl:mainfrom
nghiadaulau:feat/agent-ai-base-url
Closed

feature(agent): add base_url for the detect and analyze chat agents#245
nghiadaulau wants to merge 1 commit into
VersusControl:mainfrom
nghiadaulau:feat/agent-ai-base-url

Conversation

@nghiadaulau

Copy link
Copy Markdown
Member

Summary

Adds agent.ai.base_url (env AGENT_AI_BASE_URL) so the detect and
analyze chat agents can target any OpenAI-compatible endpoint — Ollama,
vLLM, LocalAI, an LLM gateway in front of AWS Bedrock, or Gemini's
OpenAI-compatible endpoint. Inference can stay inside the operator's own
network, which is a hard requirement for self-hosted and regulated
deployments.

The missing link

detect.Options and analyze.Options already carry a BaseURL field
and forward it to the Eino chat model — but it was documented test-only and
the factory never set it from config. The embedder path already wires
EmbeddingBaseURL; the chat path was the gap. This PR closes it.

Changes

  • AgentAIConfig.BaseURL + per-task overrides detect.base_url /
    analyze.base_url, carried through Resolve() and the clone_config
    deep-clone (the config triple-touch: struct + clone + yaml).
  • factory_ai.go threads the resolved base_url into both detect.Options
    and analyze.Options.
  • config/config.yaml, Helm (agent.ai.baseUrl + agent.ai.analyze.baseUrl
    values + configmap rendering), and the detect-mode docs (replaces the
    now-obsolete "chat endpoint is hard-coded" note).

Empty base_url keeps the OpenAI default (api.openai.com/v1), so existing
deployments are unchanged.

Testing

  • Config: Resolve carries the shared base_url and lets a per-task
    value override it; cloneConfig preserves base_url at the shared,
    detect, and analyze levels (guards the triple-touch landmine).
  • Factory (httptest): BuildAIs with cfg.AI.BaseURL set to a local
    test server, then a real detect Run — asserts the agent's chat client
    hits the configured endpoint, not api.openai.com.
  • Live: verified against Gemini's OpenAI-compatible endpoint
    (/v1beta/openai/chat/completions) — the request authenticates and the
    endpoint accepts the OpenAI request shape (a real completion needs quota
    enabled on the key).
  • gofmt, go vet, go build ./..., go test -race ./pkg/config ./pkg/agent
    green; helm template renders the base_url keys (and omits them when
    empty).

Checklist

  • Table-driven / httptest tests for the new behavior
  • Config triple-touch (struct + clone_config + config.yaml)
  • Helm values + configmap mirrored
  • Backward compatible (empty base_url = OpenAI default)
  • House conventions (feature: prefix, import grouping); docs + CHANGELOG

agent.ai.base_url (env AGENT_AI_BASE_URL) points both chat agents at any
OpenAI-compatible endpoint — Ollama / vLLM / LocalAI, an LLM gateway in
front of Bedrock, or Gemini's OpenAI-compatible endpoint — so inference
can stay inside the operator's own network (a compliance requirement for
self-hosted and regulated environments).

detect.Options and analyze.Options already accepted a BaseURL (test-only
until now); the factory simply never set it from config. This wires the
missing link:

- AgentAIConfig.BaseURL + per-task overrides on detect/analyze, carried
  through Resolve() and the clone_config deep-clone (triple-touch).
- factory_ai threads the resolved base_url into both Options.
- config.yaml, Helm values + configmap, and the detect-mode docs.

Empty base_url keeps the OpenAI default, so existing deployments are
unchanged. Tests: Resolve carries/overrides base_url; clone preserves it
at every level; a factory httptest test asserts the detect agent calls the
configured endpoint.
nghiadaulau added a commit to nghiadaulau/versus-incident that referenced this pull request Jun 20, 2026
Add agent.ai.provider — "openai" (default) or "gemini" — instead of a raw
base_url. ProviderBaseURL maps the provider to its OpenAI-compatible chat
endpoint internally (both backends are OpenAI-compatible, so only the base
URL changes), so operators pick a short name instead of a long URL. Wired
through detect + analyze (per-task agent.ai.analyze.provider override),
config.yaml (env AGENT_AI_PROVIDER) and the Helm chart. Empty = openai, so
existing deployments are unchanged.

Supersedes VersusControl#245 (base_url).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nghiadaulau

Copy link
Copy Markdown
Member Author

Superseded by #264 — replaced the verbose base_url with a friendly provider enum (openai/gemini) that maps to the OpenAI-compatible endpoint internally. Same goal, cleaner surface.

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.

1 participant