Skip to content

fix(python): preserve explicit LLMClient callbacks - #268

Open
Chen Yufeiyang (feiiiiii5) wants to merge 1 commit into
braintrustdata:mainfrom
feiiiiii5:codex/fix-custom-llm-client-callbacks
Open

Chen Yufeiyang (feiiiiii5) wants to merge 1 commit into
braintrustdata:mainfrom
feiiiiii5:codex/fix-custom-llm-client-callbacks

Conversation

@feiiiiii5

Copy link
Copy Markdown

LLMClient accepts explicit completion, embedding and moderation callbacks, but __post_init__ overwrites them with SDK defaults after detecting customization. Requests therefore reach the SDK instead of the supplied callbacks; an explicitly supplied rate-limit exception class is also discarded.

Configure each field only when it is None, in both supported SDK configuration branches. Partial customization continues to configure the other methods automatically. This follows the explicit-method contract documented in the class and introduced by #121.

Validation with the frozen lockfile, Python 3.12.8, OpenAI 2.41.0 and the dev/scipy/LiteLLM extras:

  • All 16 new regression cases fail on a5dd171; the fixed test_oai.py passes 35 tests.
  • The complete offline Python selection passes 90 tests, with 16 live-provider cases deselected.
  • All configured pre-commit hooks pass on both changed files, using the configured Black 24.10.0 and Ruff 0.12.7.
  • git diff --check passes; the lockfile is unchanged.

The v1-interface tests use the real OpenAI SDK with httpx.MockTransport; v0 uses the repository's existing compatibility fixture. Sync/async and full/partial customization exercise actual callback results, custom rate-limit retries and default-method requests. No live model calls were made.

Offline test scope

The 16 omitted cases are the two live embedding tests, four live LLM tests, the moderation and partial live tests, and eight test_ragas_retrieval parameter instances. A collection hook matches exact file/function names; mocked tests, including all nine LiteLLM cases, remain selected.

Formatting command: pre-commit run --files py/autoevals/oai.py py/autoevals/test_oai.py.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T16:19:39.877694Z 01066f1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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