Skip to content

CI_BUG: OpenAI client instantiated at import time breaks contributor CI #496

Description

@steadhac

Problem
The test suite fails on contributor forks with:

openai.OpenAIError: Missing credentials. Please pass an api_key or set the OPENAI_API_KEY environment variable.
This happens on every test run — even tests that have nothing to do with the LLM — because LLMClient() is instantiated at module load time in finbot/core/llm/client.py:70:

llm_client = LLMClient()  # runs at import, not on first use
When any test imports finbot.main, it triggers the full chain:
badges.pyctf.evaluatorsdetectors.__init__indirect_exfil.pyLLMClient() → crash.

The CI workflow intentionally does not require an OpenAI key — the tests being run (vendor isolation, session management, user isolation, redis streams) have no LLM dependency. The module-level instantiation introduced in b180679 broke contributor CI silently.

Root Cause
b180679 added indirect_exfil.py, which imports LLMJudge at the top level. This triggers eager LLMClient() construction, which defaults to the openai provider and raises immediately without a key.

Fix
Set LLM_PROVIDER=mock at the job level in .github/workflows/test.yml. The mock provider is already implemented and skips all credential checks.

jobs:
test:
runs-on: ubuntu-latest
env:
LLM_PROVIDER: mock
A longer-term fix would be to lazy-initialize llm_client in client.py so it only constructs on first call, not on import.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions