mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-27 17:49:22 +00:00
Two more from CodeRabbit review, both verified against the code before fixing. 1. The cache key ignored OPENAI_BASE_URL / OPENAI_API_BASE. `_get_client_params` resolves the endpoint as base_url or api_base or OPENAI_BASE_URL or OPENAI_API_BASE, but `_model_cache_key` stopped at the two fields. An instance pointed at a proxy purely through the environment was therefore keyed as https://api.openai.com/v1 -- reintroducing exactly the cross-endpoint leakage the tuple key was added to prevent. Both now derive from a single `_resolved_base_url()`, so the client config and the cache keys can't disagree about what "endpoint" means. OPENAI_BASE_URL=https://proxy.internal/v1 -> ('https://proxy.internal/v1', 'gpt-5-pro') (was api.openai.com) base_url= explicit -> wins over env neither set -> api.openai.com 2. The responses-only branch of `_is_recoverable_completion_error` was dead. NotFoundError is caught by an earlier handler that logs, emits _emit_call_failed_event and re-raises as ValueError, so the 404 half never reached the generic guard. That both reported a failure the user never experiences and wrapped away the NotFoundError the retry needs to recognize. The same guard now sits in both NotFoundError handlers. Verified live -- a pro model still recovers, and the spurious event is gone: pro model -> 'PONG' learned -> {('https://api.openai.com/v1', 'gpt-5-pro')} spurious LLMCallFailedEvent -> 0 (previously fired) spurious failure logs -> 0 Tests: 6 new cases for endpoint resolution (env proxy, explicit override, default, and that a proxy doesn't inherit OpenAI's learning) and for the NotFoundError handler deferring to the retry without emitting a failure event. 1049 passed across tests/llms, tests/agents and test_agent_utils (1 pre-existing unrelated failure from a local OLLAMA_API_KEY env leak). Ruff + mypy clean.