Skip to content

Allow propagating a 'strict' argument in the JS SDK to fail invalid prompts - #621

Merged
Ankur Goyal (ankrgyl) merged 6 commits into
mainfrom
strict-mode
Mar 31, 2025
Merged

Allow propagating a 'strict' argument in the JS SDK to fail invalid prompts#621
Ankur Goyal (ankrgyl) merged 6 commits into
mainfrom
strict-mode

Conversation

@ankrgyl

Copy link
Copy Markdown
Contributor

No description provided.

let curr: unknown = row;
for (const p of path) {
if (!isObjectOrArray(curr)) {
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: probably want to return undefined to disambiguate from a path with a value of null

Comment thread js/src/prompt.test.ts
for (const strict of [true, false]) {
for (const shouldFail of [true, false]) {
for (const testNull of [true, false]) {
testPromptBuild({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a nested object and array path test in the template as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Should we add it in Python too?

@ankrgyl

Copy link
Copy Markdown
Contributor Author

Not yet.

@ankrgyl
Ankur Goyal (ankrgyl) merged commit a29e7d1 into main Mar 31, 2025
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the strict-mode branch March 10, 2026 17:35
Luca Forstner (lforst) added a commit that referenced this pull request 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

- [x] `pnpm run fix:formatting` — clean
- [x] `pnpm run lint` — 0 errors (pre-existing warnings only)
- [x] `npx tsc --noEmit -p .` — passes
- [x] `npx vitest run src/functions/invoke.test.ts` — 5/5 passing
- [x] `npx vitest run src/logger.test.ts -t loadPrompt` — passes
- [ ] CI green

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Luca Forstner <luca.forstner@gmail.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.

3 participants