feat(invoke): expose overrides field on invoke()#489
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 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>
|
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: ``` `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:
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. |
Summary
overrideskwarg to bothinvoke()overloads and the main signature, threaded through to the request body sent 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 includesoverrides, 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_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 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 skippedcd 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