Skip to content

fix: Make sure params get passed through for compiled prompt#1558

Merged
Abhijeet Prasad (AbhiPrasad) merged 3 commits intomainfrom
abhi-fix-prompt-build-types
Mar 18, 2026
Merged

fix: Make sure params get passed through for compiled prompt#1558
Abhijeet Prasad (AbhiPrasad) merged 3 commits intomainfrom
abhi-fix-prompt-build-types

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

resolves https://linear.app/braintrustdata/issue/BT-4378/typescript-sdk-promptbuild-fields-response-format-tool-choice

This fixes a bug with typings where params were not being passed through correctly.

import OpenAI from "openai";
import { Prompt } from "braintrust";

declare const prompt: Prompt;

const params = prompt.build(
  { topic: "TypeScript" },
  { flavor: "chat" },
);

// Before the fix, these would fail
// Property 'temperature' does not exist on type 'CompiledPrompt<"chat">'
const temperature = params.temperature;
const responseFormat = params.response_format;
const toolChoice = params.tool_choice;

I didn't add a test for this because it's just a types change, but lmk and I can add a set of type check tests.

@AbhiPrasad
Copy link
Copy Markdown
Member Author

Hmm, this is a breaking change, but it's one for correctness. We can just leave this PR until the next major version though.

@lforst
Copy link
Copy Markdown
Member

Why exactly is this a breaking change? It doesn't seem like one cause we simply widen a return type no? The compatibility CI check is sometimes overly sensitive because it's literally comparing the text of TS definitions.

@AbhiPrasad
Copy link
Copy Markdown
Member Author

Ah okay we are fine. I over though it. We did break params.response_format.json_schema.schema, but that would have been busted before anyway. So this change is safe.

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) merged commit c9d76a6 into main Mar 18, 2026
48 checks passed
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) deleted the abhi-fix-prompt-build-types branch March 18, 2026 12:35
Luca Forstner (lforst) added a commit that referenced this pull request Mar 18, 2026
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