From c1a913469669a5921956b2a6cf6bd093beffa9a7 Mon Sep 17 00:00:00 2001 From: paultancre-bt Date: Wed, 3 Jun 2026 13:02:57 +0100 Subject: [PATCH] feat(invoke): expose overrides field on invoke() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- py/src/braintrust/functions/invoke.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/py/src/braintrust/functions/invoke.py b/py/src/braintrust/functions/invoke.py index 5f48f2cd..ded7ed46 100644 --- a/py/src/braintrust/functions/invoke.py +++ b/py/src/braintrust/functions/invoke.py @@ -53,6 +53,7 @@ def invoke( stream: Literal[False] | None = None, mode: ModeType | None = None, strict: bool | None = None, + overrides: dict[str, Any] | None = None, org_name: str | None = None, api_key: str | None = None, app_url: str | None = None, @@ -81,6 +82,7 @@ def invoke( stream: Literal[True] = True, mode: ModeType | None = None, strict: bool | None = None, + overrides: dict[str, Any] | None = None, org_name: str | None = None, api_key: str | None = None, app_url: str | None = None, @@ -108,6 +110,7 @@ def invoke( stream: bool = False, mode: ModeType | None = None, strict: bool | None = None, + overrides: dict[str, Any] | None = None, org_name: str | None = None, api_key: str | None = None, app_url: str | None = None, @@ -136,6 +139,10 @@ def invoke( will return an array of JSON objects with one object per tool call. strict: Whether to use strict mode for the function. If true, the function will throw an error if the variable names in the prompt do not match the input keys. + overrides: Per-call deep-merge into the resolved function data server-side. Useful for + facet, code, global, and remote_eval functions (for example, overriding a facet's + ``model`` or a global function's ``config``). Has no effect on prompt functions, + whose parameters live on a separate field that the override path does not touch. org_name: The name of the Braintrust organization to use. api_key: The API key to use for authentication. app_url: The URL of the Braintrust application. @@ -198,6 +205,8 @@ def invoke( request["mode"] = mode if strict is not None: request["strict"] = strict + if overrides is not None: + request["overrides"] = overrides headers = { "Accept": "text/event-stream" if stream else "application/json",