Skip to content

Commit c1a9134

Browse files
paultancre-btclaude
andcommitted
feat(invoke): expose overrides field on invoke()
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>
1 parent 0d6c87d commit c1a9134

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

py/src/braintrust/functions/invoke.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def invoke(
5353
stream: Literal[False] | None = None,
5454
mode: ModeType | None = None,
5555
strict: bool | None = None,
56+
overrides: dict[str, Any] | None = None,
5657
org_name: str | None = None,
5758
api_key: str | None = None,
5859
app_url: str | None = None,
@@ -81,6 +82,7 @@ def invoke(
8182
stream: Literal[True] = True,
8283
mode: ModeType | None = None,
8384
strict: bool | None = None,
85+
overrides: dict[str, Any] | None = None,
8486
org_name: str | None = None,
8587
api_key: str | None = None,
8688
app_url: str | None = None,
@@ -108,6 +110,7 @@ def invoke(
108110
stream: bool = False,
109111
mode: ModeType | None = None,
110112
strict: bool | None = None,
113+
overrides: dict[str, Any] | None = None,
111114
org_name: str | None = None,
112115
api_key: str | None = None,
113116
app_url: str | None = None,
@@ -136,6 +139,10 @@ def invoke(
136139
will return an array of JSON objects with one object per tool call.
137140
strict: Whether to use strict mode for the function. If true, the function will throw an
138141
error if the variable names in the prompt do not match the input keys.
142+
overrides: Per-call deep-merge into the resolved function data server-side. Useful for
143+
facet, code, global, and remote_eval functions (for example, overriding a facet's
144+
``model`` or a global function's ``config``). Has no effect on prompt functions,
145+
whose parameters live on a separate field that the override path does not touch.
139146
org_name: The name of the Braintrust organization to use.
140147
api_key: The API key to use for authentication.
141148
app_url: The URL of the Braintrust application.
@@ -198,6 +205,8 @@ def invoke(
198205
request["mode"] = mode
199206
if strict is not None:
200207
request["strict"] = strict
208+
if overrides is not None:
209+
request["overrides"] = overrides
201210

202211
headers = {
203212
"Accept": "text/event-stream" if stream else "application/json",

0 commit comments

Comments
 (0)