Repository navigation
fix(agent): match ARTEX_LLM_PROVIDER case-insensitively - #140
Merged
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
agent.FromEnvswitched on the rawARTEX_LLM_PROVIDERvalue.Ollama,OpenAIor a value with a trailing space matched no case and fell through to thedefault:branch, which is anthropic. WithARTEX_LLM_PROVIDER=Ollama,ARTEX_LLM_BASE_URL=http://ollama-host:11434and anANTHROPIC_API_KEYset, 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 inagent/provider.go.Verification
agent/provider_env_test.go(TestFromEnvProviderIsCaseInsensitive) coversOllama,OLLAMA,OpenAI,OpenAI-ResponsesandAnthropic. Before the fix it failed:"Ollama": format=anthropic key="sk-ant-secret". After the fix it passes.go build ./...andgo vet ./...: OK (go1.26.7, linux/amd64).go test ./agent ./config -count=1: ok. The existingTestOllamaFromEnv*tests in./serverpass.Not verified: the full
./serversuite against Postgres. No database was available on the test machine, so CI covers that.