Skip to content

feat(invoke): expose overrides field on invoke()#2087

Merged
Luca Forstner (lforst) merged 3 commits into
mainfrom
paul/invoke-overrides
Jun 3, 2026
Merged

feat(invoke): expose overrides field on invoke()#2087
Luca Forstner (lforst) merged 3 commits into
mainfrom
paul/invoke-overrides

Conversation

@paultancre-bt
Copy link
Copy Markdown
Contributor

@paultancre-bt paultancre-bt commented Jun 3, 2026

Summary

  • Add overrides field to InvokeFunctionArgs and pass it through in the request body 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 in generated_types.ts includes overrides, 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 strict was added in #621.

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 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 — clean
  • pnpm run lint — 0 errors (pre-existing warnings only)
  • npx tsc --noEmit -p . — passes
  • npx vitest run src/functions/invoke.test.ts — 5/5 passing
  • npx vitest run src/logger.test.ts -t loadPrompt — passes
  • CI green

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>
@lforst Luca Forstner (lforst) merged commit 322cccd into main Jun 3, 2026
48 checks passed
@lforst Luca Forstner (lforst) deleted the paul/invoke-overrides branch June 3, 2026 12:48
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>
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.

2 participants