feat(invoke): expose overrides field on invoke()#2087
Merged
Conversation
The /function/invoke REST endpoint accepts an `overrides` field that deep-merges into the resolved function data server-side, but `invoke()` does not pass it through. The SDK destructures known fields and rebuilds the request, so the parameter was dropped before reaching the wire even via type assertion. Adds `overrides` to InvokeFunctionArgs and threads it through the request body. Purely additive — no schema or server changes. Documents the prompt-function limitation: overrides deep-merge into function_data only, so prompt parameters (which live on prompt_data) are not affected by this path. Pylon: braintrustdata/braintrust#17344 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks
Luca Forstner (lforst)
approved these changes
Jun 3, 2026
Abhijeet Prasad (AbhiPrasad)
added a commit
to braintrustdata/braintrust-sdk-python
that referenced
this pull request
Jun 3, 2026
## Summary - Add `overrides` kwarg to both `invoke()` overloads and the main signature, threaded through to the request body sent to `/function/invoke`. ## Context The `/function/invoke` REST endpoint accepts an `overrides` field that deep-merges into the resolved function data server-side (see `applyFunctionDataOverrides` in `api-ts/src/proxy/call.ts`). The wire schema includes `overrides`, and the proxy applies it, but the Python SDK builds the request body from a whitelist of known kwargs, so the parameter was dropped before reaching the wire. Mirrors the analogous TS SDK PR at braintrustdata/braintrust-sdk-javascript#2087. **Limitation:** overrides deep-merge into `function_data` only. Prompt-type functions have their parameters (model, options.params, messages, tool_functions, etc.) on a separate `prompt_data` field that the override path does not touch — for prompt functions this passthrough has no effect. The docstring documents this. The matching docs PR (braintrustdata/braintrust#15157) documents the same limitation user-facing. Related Pylon ticket: braintrustdata/braintrust#17344. ## Test plan - [x] `cd py && uv run pytest src/braintrust/functions/test_invoke.py` — 5 passed, 3 skipped - [x] `cd py && uv run nox -s test_types` — 16 passed (mypy + pyright + runtime type tests) - [x] `mise exec -- pre-commit run --files py/src/braintrust/functions/invoke.py` — ruff format/check/codespell all pass Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
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.
Summary
overridesfield toInvokeFunctionArgsand pass it through in the request body to/function/invoke.Context
The
/function/invokeREST endpoint accepts anoverridesfield that deep-merges into the resolved function data server-side (seeapplyFunctionDataOverridesinapi-ts/src/proxy/call.ts). The wire schema ingenerated_types.tsincludesoverrides, and the proxy applies it, but the SDK destructures known fields and rebuilds the request, so the parameter was dropped before reaching the wire even via type assertion.The change is purely additive — no schema or server changes. Mirrors how
strictwas added in #621.Limitation: overrides deep-merge into
function_dataonly. Prompt-type functions have their parameters (model, options.params, messages, tool_functions, etc.) on a separateprompt_datafield that the override path does not touch — for prompt functions this passthrough has no effect. The JSDoc on the new field documents this. The matching docs PR (braintrustdata/braintrust#15157) documents the same limitation user-facing.Related Pylon ticket: braintrustdata/braintrust#17344.
Test plan
pnpm run fix:formatting— cleanpnpm run lint— 0 errors (pre-existing warnings only)npx tsc --noEmit -p .— passesnpx vitest run src/functions/invoke.test.ts— 5/5 passingnpx vitest run src/logger.test.ts -t loadPrompt— passes