Skip to content

test(agent): pass LOCALAI_API_KEY to every live-LLM agent in the suite - #521

Open
walcz-de wants to merge 1 commit into
mudler:mainfrom
walcz-de:pr/tests-llm-api-key
Open

walcz-de wants to merge 1 commit into
mudler:mainfrom
walcz-de:pr/tests-llm-api-key

Conversation

@walcz-de

Copy link
Copy Markdown
Contributor

The agent suite reads LOCALAI_API_KEY into apiKeyURL (core/agent/agent_suite_test.go:18), but only two specs pass it to the agent. Against a LocalAI with authentication enabled, the identity specs fail before they test anything:

failed to prepare identity: failed to generate JSON from structure: error, status code: 401,
status: 401 Unauthorized, message: An authentication key is required

This adds WithLLMAPIKey(apiKeyURL) wherever an agent talks to apiURL (2 in state_test.go, 4 in agent_test.go). With the variable unset nothing changes, since an empty key sends no header.

Tests: against an authenticated LocalAI, ginkgo --label-filter='!E2E' --focus identity ./core/agent/ went from 1 failed to 3/3 passed; go vet ./core/agent is clean. Test-only change, so no docs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKrqvpahnF5rKBzf5Z3rAE

The suite reads LOCALAI_API_KEY into apiKeyURL, but only two specs passed it
to the agent. Against a LocalAI with authentication enabled, the identity
specs (and the E2E action specs) fail with "401 ... An authentication key is
required". Pass WithLLMAPIKey(apiKeyURL) wherever the agent talks to apiURL;
with the variable unset nothing changes.

Docs-Not-Needed: test-only change, no user-facing behaviour

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Stefan Walcz <stefan.walcz@walcz.de>
walcz-de added a commit to walcz-de/LocalAI that referenced this pull request Oct 22, 2026
…el, mudler/LocalAGI#521)

Nur Testdateien: WithLLMAPIKey(apiKeyURL) in state_test.go/agent_test.go — die Go-Suite des Nachtlaufs laeuft seit der LocalAI-Anmeldung (mudler#1344) sonst in 401 (agntsio mudler#1357).

Assisted-by: Claude Code:claude-opus-5-5
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