Skip to content

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

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
paul/invoke-overrides
Jun 3, 2026
Merged

feat(invoke): expose overrides field on invoke()#489
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
paul/invoke-overrides

Conversation

@paultancre-bt
Copy link
Copy Markdown

@paultancre-bt paultancre-bt commented 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

  • cd py && uv run pytest src/braintrust/functions/test_invoke.py — 5 passed, 3 skipped
  • cd py && uv run nox -s test_types — 16 passed (mypy + pyright + runtime type tests)
  • mise exec -- pre-commit run --files py/src/braintrust/functions/invoke.py — ruff format/check/codespell all pass

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 builds the request body from a
whitelist, so the parameter was dropped before reaching the wire.

Adds `overrides` to the two `@overload` signatures and the main `invoke`
signature, and threads it through the request dict. 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>
@paultancre-bt
Copy link
Copy Markdown
Author

CI is currently red across all nox shards, but this is unrelated to the change in this PR — it's a repo-wide breakage that should be looked at.

Root cause: every nox session that loads VCR fails at conftest import time with:

```
.nox/test_crewai-1-13-0/lib/python3.10/site-packages/vcr/stubs/aiohttp_stubs.py:21: in
E AttributeError: module 'aiohttp.streams' has no attribute 'AsyncStreamReaderMixin'
```

`vcrpy` references `AsyncStreamReaderMixin` from `aiohttp.streams`, which the installed `aiohttp` version no longer exposes. The failure happens before any test in this PR's code path runs.

Verified unrelated to this PR:

  • Same exact `59 fail / 21 pass / 2 skipping` pattern on PR fix: honor org git metadata settings for experiments #486 (which doesn't touch `invoke.py`).
  • The 21 passing checks are the non-VCR sessions (changeset / typecheck / pylint / etc).
  • Locally on main + this branch: `uv run pytest src/braintrust/functions/test_invoke.py` passes (5 passed, 3 skipped), and `uv run nox -s test_types` passes (16 passed).

Likely needs either a `vcrpy` pin past the breaking version or an `aiohttp` pin in `py/pyproject.toml` — repo-level CI fix, separate from this PR.

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) enabled auto-merge (squash) June 3, 2026 16:36
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) merged commit a1294ff into main Jun 3, 2026
82 checks passed
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) deleted the paul/invoke-overrides branch June 3, 2026 16:36
@AbhiPrasad
Copy link
Copy Markdown
Member

released with https://github.com/braintrustdata/braintrust-sdk-python/releases/tag/py-sdk-v0.24.0!

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