Skip to content

fix(agent): match ARTEX_LLM_PROVIDER case-insensitively - #140

Merged
BaaRai merged 1 commit into
mainfrom
fix/llm-provider-env-case
Nov 3, 2026
Merged

BaaRai merged 1 commit into
mainfrom
fix/llm-provider-env-case

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Bug

agent.FromEnv switched on the raw ARTEX_LLM_PROVIDER value. Ollama, OpenAI or a value with a trailing space matched no case and fell through to the default: branch, which is anthropic. With ARTEX_LLM_PROVIDER=Ollama, ARTEX_LLM_BASE_URL=http://ollama-host:11434 and an ANTHROPIC_API_KEY set, the engine started as an Anthropic provider and sent the Anthropic key to the Ollama host. It also ignored the operator's choice without logging anything.

Fix

Normalize the value with strings.ToLower(strings.TrimSpace(...)) before the switch. This is a one-line change in agent/provider.go.

Verification

  • New agent/provider_env_test.go (TestFromEnvProviderIsCaseInsensitive) covers Ollama, OLLAMA, OpenAI, OpenAI-Responses and Anthropic. Before the fix it failed: "Ollama": format=anthropic key="sk-ant-secret". After the fix it passes.
  • go build ./... and go vet ./...: OK (go1.26.7, linux/amd64).
  • go test ./agent ./config -count=1: ok. The existing TestOllamaFromEnv* tests in ./server pass.

Not verified: the full ./server suite against Postgres. No database was available on the test machine, so CI covers that.

FromEnv compared the raw value, so "Ollama" or "OpenAI" matched no case and
fell through to the anthropic default. With ARTEX_LLM_PROVIDER=Ollama and an
ANTHROPIC_API_KEY set, the Anthropic key was sent to the Ollama base URL.
@BaaRai
BaaRai merged commit 0d9602d into main Nov 3, 2026
3 checks passed
@BaaRai BaaRai mentioned this pull request Nov 4, 2026
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