:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(aio): add response format state to the playground prompt logic (#119374)
Juraj Majerik4e6bc1066b15
diff --git a/products/ai_observability/frontend/playground/llmPlaygroundLogic.test.ts b/products/ai_observability/frontend/playground/llmPlaygroundLogic.test.tsindex a29c80964dfe..082ced8aca09 100644--- a/products/ai_observability/frontend/playground/llmPlaygroundLogic.test.ts+++ b/products/ai_observability/frontend/playground/llmPlaygroundLogic.test.ts@@ -1811,6 +1811,10 @@ describe('llmPlaygroundLogic', () => {thinking: true,reasoning_effort: 'high',tools: [{ type: 'function', function: { name: 'lookup' } }],+ response_format: {+ type: 'json_schema',+ json_schema: { name: 'verdict', schema: { type: 'object' }, strict: true },+ },messages: [{ role: 'user', content: 'Hi {{name}}' }],},},@@ -1831,6 +1835,10 @@ describe('llmPlaygroundLogic', () => {expect(llmPlaygroundPromptsLogic.values.thinking).toBe(true)expect(llmPlaygroundPromptsLogic.values.reasoningLevel).toBe('high')expect(llmPlaygroundPromptsLogic.values.tools).toEqual([{ type: 'function', function: { name: 'lookup' } }])+ expect(llmPlaygroundPromptsLogic.values.responseFormat).toEqual({+ type: 'json_schema',+ json_schema: { name: 'verdict', schema: { type: 'object' }, strict: true },+ })expect(llmPlaygroundPromptsLogic.values.model).toBe('gpt-5')})diff --git a/products/ai_observability/frontend/playground/llmPlaygroundPromptsLogic.ts b/products/ai_observability/frontend/playground/llmPlaygroundPromptsLogic.tsindex 973acbbb9005..d4b951d1f9f1 100644--- a/products/ai_observability/frontend/playground/llmPlaygroundPromptsLogic.ts+++ b/products/ai_observability/frontend/playground/llmPlaygroundPromptsLogic.ts@@ -42,6 +42,16 @@ export function cleanSourceSearchParams(searchParams: Record<string, any>): Recoexport type MessageRole = 'user' | 'assistant' | 'system' | 'tool'export type ReasoningLevel = 'minimal' | 'low' | 'medium' | 'high' | null+// The OpenAI `response_format` shape, so an SDK that fetches the prompt can pass it to a provider unchanged.+export interface PlaygroundResponseFormat {+ type: 'json_schema'+ json_schema: {+ name: string+ schema: Record<string, unknown>+ strict: boolean+ }+}+export interface MessageToolCall {id: stringname: string@@ -71,6 +81,7 @@ export interface PromptConfig {thinking: booleanreasoningLevel: ReasoningLeveltools: Record<string, unknown>[] | null+ responseFormat: PlaygroundResponseFormat | nullsourceType: 'prompt' | 'evaluation' | nullsourcePromptName: string | nullsourcePromptVersion: number | null@@ -169,6 +180,7 @@ export function createPromptConfig(partial: Partial<PromptConfig> = {}): PromptCthinking: partial.thinking ?? false,reasoningLevel: partial.reasoningLevel ?? 'medium',tools: partial.tools ?? null,+ responseFormat: partial.responseFormat ?? null,sourceType: partial.sourceType ?? null,sourcePromptName: partial.sourcePromptName ?? null,sourcePromptVersion: partial.sourcePromptVersion ?? null,@@ -209,7 +221,7 @@ export interface llmPlaygroundPromptsLogicValues {editModal: {messageIndex?: numberpromptId: string- type: 'message' | 'system' | 'tools'+ type: 'message' | 'response_format' | 'system' | 'tools'} | nullhasRunnablePrompts: booleanlinkedSource: {@@ -219,6 +231,7 @@ export interface llmPlaygroundPromptsLogicValues {promptVersion: number | nulltype: 'evaluation' | 'prompt' | null}+ localResponseSchemaJsonByPromptId: Record<string, string | null>localToolsJsonByPromptId: Record<string, string | null>maxTokens: number | nullmessages: Message[]@@ -229,6 +242,8 @@ export interface llmPlaygroundPromptsLogicValues {pendingTargetProviderKeyId: string | nullpromptConfigs: PromptConfig[]reasoningLevel: ReasoningLevel+ responseFormat: PlaygroundResponseFormat | null+ responseSchemaJsonErrorByPromptId: Record<string, string | null>saving: booleanselectedProviderKeyId: string | nullsourceSetupLoading: boolean@@ -358,15 +373,22 @@ export interface llmPlaygroundPromptsLogicActions {target: {messageIndex?: numberpromptId: string- type: 'message' | 'system' | 'tools'+ type: 'message' | 'response_format' | 'system' | 'tools'} | null) => {target: {messageIndex?: number | undefinedpromptId: string- type: 'message' | 'system' | 'tools'+ type: 'message' | 'response_format' | 'system' | 'tools'} | null}+ setLocalResponseSchemaJson: (+ json: string | null,+ promptId?: string+ ) => {+ json: string | null+ promptId: string | undefined+ }setLocalToolsJson: (json: string | null,promptId?: string@@ -407,6 +429,20 @@ export interface llmPlaygroundPromptsLogicActions {promptId: string | undefinedreasoningLevel: ReasoningLevel}+ setResponseFormat: (+ responseFormat: PlaygroundResponseFormat | null,+ promptId?: string+ ) => {+ promptId: string | undefined+ responseFormat: PlaygroundResponseFormat | null+ }+ setResponseSchemaJsonError: (+ promptId: string,+ error: string | null+ ) => {+ error: string | null+ promptId: string+ }setSourceNames: (promptName: string | null,evaluationName: string | null,@@ -491,6 +527,7 @@ export interface llmPlaygroundPromptsLogicMeta {topP: (activePromptConfig: PromptConfig) => number | nullreasoningLevel: (activePromptConfig: PromptConfig) => ReasoningLeveltools: (activePromptConfig: PromptConfig) => Record<string, unknown>[] | null+ responseFormat: (activePromptConfig: PromptConfig) => PlaygroundResponseFormat | nullmessages: (activePromptConfig: PromptConfig) => Message[]linkedSource: (promptConfigs: PromptConfig[]) => {evaluationId: string | null@@ -527,6 +564,10 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([setThinking: (thinking: boolean, promptId?: string) => ({ thinking, promptId }),setReasoningLevel: (reasoningLevel: ReasoningLevel, promptId?: string) => ({ reasoningLevel, promptId }),setTools: (tools: Record<string, unknown>[] | null, promptId?: string) => ({ tools, promptId }),+ setResponseFormat: (responseFormat: PlaygroundResponseFormat | null, promptId?: string) => ({+ responseFormat,+ promptId,+ }),clearConversation: (promptId?: string) => ({ promptId }),setMessages: (messages: Message[], promptId?: string) => ({ messages, promptId }),deleteMessage: (index: number, promptId?: string) => ({ index, promptId }),@@ -546,12 +587,18 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([}),setupPlaygroundFromEvent: (payload: PlaygroundSetupPayload) => ({ payload }),setLocalToolsJson: (json: string | null, promptId?: string) => ({ json, promptId }),+ setLocalResponseSchemaJson: (json: string | null, promptId?: string) => ({ json, promptId }),clearPendingTargetModel: true,setEditModal: (- target: { type: 'tools' | 'system' | 'message'; promptId: string; messageIndex?: number } | null+ target: {+ type: 'tools' | 'system' | 'message' | 'response_format'+ promptId: string+ messageIndex?: number+ } | null) => ({ target }),toggleCollapsed: (key: string) => ({ key }),setToolsJsonError: (promptId: string, error: string | null) => ({ promptId, error }),+ setResponseSchemaJsonError: (promptId: string, error: string | null) => ({ promptId, error }),setSourceSetupLoading: (isLoading: boolean) => ({ isLoading }),applySavedModelSelection: (selection: {model: string@@ -636,6 +683,10 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([state: PromptConfig[],{ tools, promptId }: { tools: Record<string, unknown>[] | null; promptId?: string }) => updatePromptConfigs(state, promptId, (prompt) => ({ ...prompt, tools })),+ setResponseFormat: (+ state: PromptConfig[],+ { responseFormat, promptId }: { responseFormat: PlaygroundResponseFormat | null; promptId?: string }+ ) => updatePromptConfigs(state, promptId, (prompt) => ({ ...prompt, responseFormat })),clearConversation: (state: PromptConfig[], { promptId }: { promptId?: string }) =>updatePromptConfigs(state, promptId, (prompt) => ({ ...prompt, messages: [] })),setMessages: (@@ -797,6 +848,31 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([},},],+ localResponseSchemaJsonByPromptId: [+ {} as Record<string, string | null>,+ {+ resetPlayground: () => ({}),+ setLocalResponseSchemaJson: (+ state: Record<string, string | null>,+ { json, promptId }: { json: string | null; promptId?: string }+ ) => {+ if (!promptId) {+ return state+ }+ return { ...state, [promptId]: json }+ },+ setResponseFormat: (state: Record<string, string | null>, { promptId }: { promptId?: string }) => {+ if (!promptId) {+ return state+ }+ return { ...state, [promptId]: null }+ },+ removePromptConfig: (state: Record<string, string | null>, { promptId }: { promptId: string }) => {+ const { [promptId]: _, ...rest } = state+ return rest+ },+ },+ ],pendingTargetModel: [null as string | null,{@@ -848,7 +924,11 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([},],editModal: [- null as { type: 'tools' | 'system' | 'message'; promptId: string; messageIndex?: number } | null,+ null as {+ type: 'tools' | 'system' | 'message' | 'response_format'+ promptId: string+ messageIndex?: number+ } | null,{resetPlayground: () => null,setEditModal: (@@ -856,7 +936,11 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([{target,}: {- target: { type: 'tools' | 'system' | 'message'; promptId: string; messageIndex?: number } | null+ target: {+ type: 'tools' | 'system' | 'message' | 'response_format'+ promptId: string+ messageIndex?: number+ } | null}) => target,},@@ -885,6 +969,20 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([},},],+ responseSchemaJsonErrorByPromptId: [+ {} as Record<string, string | null>,+ {+ resetPlayground: () => ({}),+ setResponseSchemaJsonError: (+ state: Record<string, string | null>,+ { promptId, error }: { promptId: string; error: string | null }+ ) => ({ ...state, [promptId]: error }),+ removePromptConfig: (state: Record<string, string | null>, { promptId }: { promptId: string }) => {+ const { [promptId]: _, ...rest } = state+ return rest+ },+ },+ ],sourceSetupLoading: [false as boolean,{@@ -947,6 +1045,10 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([(s) => [s.activePromptConfig],(activePromptConfig: PromptConfig): Record<string, unknown>[] | null => activePromptConfig.tools,],+ responseFormat: [+ (s) => [s.activePromptConfig],+ (activePromptConfig: PromptConfig): PlaygroundResponseFormat | null => activePromptConfig.responseFormat,+ ],messages: [(s) => [s.activePromptConfig],(activePromptConfig: PromptConfig): Message[] => activePromptConfig.messages,@@ -1042,6 +1144,11 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([tool_count: tools?.length ?? 0,})},+ setResponseFormat: ({ responseFormat }) => {+ posthog.capture('llma playground response format configured', {+ action: responseFormat ? 'set' : 'clear',+ })+ },setupPlaygroundFromEvent: async ({ payload }) => {const sourceType = payload.sourceType ?? (payload.input ? 'trace' : null)@@ -1101,6 +1208,7 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([thinking: parsedConfig.thinking,reasoningLevel: parsedConfig.reasoningLevel,tools: parsedConfig.tools,+ responseFormat: parsedConfig.responseFormat,messages: parsedConfig.messages,})))@@ -1261,6 +1369,7 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([action: 'save_to_linked_prompt',with_messages: prompt.messages.length > 0,with_tools: !!prompt.tools?.length,+ with_response_format: !!prompt.responseFormat,with_model_config: !!modelConfig,})try {@@ -1363,6 +1472,7 @@ export const llmPlaygroundPromptsLogic = kea<llmPlaygroundPromptsLogicType>([action: 'save_as_new_prompt',with_messages: prompt.messages.length > 0,with_tools: !!prompt.tools?.length,+ with_response_format: !!prompt.responseFormat,with_model_config: !!modelConfig,})try {diff --git a/products/ai_observability/frontend/playground/llmPlaygroundRunLogic.test.ts b/products/ai_observability/frontend/playground/llmPlaygroundRunLogic.test.tsindex fa8c46309658..5fee1529195d 100644--- a/products/ai_observability/frontend/playground/llmPlaygroundRunLogic.test.ts+++ b/products/ai_observability/frontend/playground/llmPlaygroundRunLogic.test.ts@@ -18,6 +18,7 @@ import {mergeUsage,} from './llmPlaygroundRunLogic'import { llmPlaygroundVariablesLogic } from './llmPlaygroundVariablesLogic'+import { createResponseFormat } from './playgroundPromptConfig'// Same contract as fetch-event-source: an error from the request or from onmessage goes to onerror,// and the request is sent again unless onerror throws.@@ -111,6 +112,8 @@ describe('llmPlaygroundRunLogic', () => {llmPlaygroundPromptsLogic.actions.setMessages([{ role: 'user', content: 'hello' }])llmPlaygroundPromptsLogic.actions.setTemperature(0.4)llmPlaygroundPromptsLogic.actions.setTopP(0.9)+ const responseFormat = createResponseFormat({ type: 'object', properties: { ok: { type: 'boolean' } } })+ llmPlaygroundPromptsLogic.actions.setResponseFormat(responseFormat)llmPlaygroundRunLogic.actions.submitPrompt()await expectLogic(logic).toFinishAllListeners()@@ -119,7 +122,9 @@ describe('llmPlaygroundRunLogic', () => {expect(streamSpy.mock.calls[0][1]?.data).toMatchObject({temperature: 0.4,top_p: 0.9,+ response_format: responseFormat,})+ expect(logic.values.comparisonItems[0]).toMatchObject({ expectsJson: true })logic.unmount()streamSpy.mockRestore()diff --git a/products/ai_observability/frontend/playground/llmPlaygroundRunLogic.ts b/products/ai_observability/frontend/playground/llmPlaygroundRunLogic.tsindex 38f9d50bd62e..a948ab7acd35 100644--- a/products/ai_observability/frontend/playground/llmPlaygroundRunLogic.ts+++ b/products/ai_observability/frontend/playground/llmPlaygroundRunLogic.ts@@ -147,6 +147,7 @@ export interface ComparisonItem {response: stringreasoning?: stringtoolCalls?: AggregatedToolCall[]+ expectsJson?: booleanprovider?: stringproviderKeyId?: string | nullerror?: boolean@@ -346,6 +347,7 @@ export const llmPlaygroundRunLogic = kea<llmPlaygroundRunLogicType>([prompt_count: runnablePrompts.length,models: runnablePrompts.map(({ prompt }) => prompt.model),has_tools: runnablePrompts.some(({ prompt }) => !!prompt.tools?.length),+ has_response_format: runnablePrompts.some(({ prompt }) => !!prompt.responseFormat),total_message_count: runnablePrompts.reduce((sum, { messagesToSend }) => sum + messagesToSend.length,0@@ -410,6 +412,7 @@ export const llmPlaygroundRunLogic = kea<llmPlaygroundRunLogicType>([response: responseText,reasoning: responseReasoning,toolCalls,+ expectsJson: !!prompt.responseFormat,provider: selectedModelProvider,providerKeyId,error: responseHasError,@@ -499,6 +502,7 @@ export const llmPlaygroundRunLogic = kea<llmPlaygroundRunLogicType>([thinking: prompt.thinking,...(providerKeyId ? { provider_key_id: providerKeyId } : {}),...(prompt.tools ? { tools: prompt.tools } : {}),+ ...(prompt.responseFormat ? { response_format: prompt.responseFormat } : {}),...(prompt.maxTokens !== null && prompt.maxTokens > 0? { max_tokens: prompt.maxTokens }: {}),@@ -616,6 +620,7 @@ export const llmPlaygroundRunLogic = kea<llmPlaygroundRunLogicType>([completion_tokens: responseUsage.completion_tokens,success: !responseHasError,has_tools: !!prompt.tools?.length,+ has_response_format: !!prompt.responseFormat,aborted: abortController.signal.aborted,})})diff --git a/products/ai_observability/frontend/playground/playgroundPromptConfig.test.ts b/products/ai_observability/frontend/playground/playgroundPromptConfig.test.tsindex 892f9713b9f8..221bbc7c8f0c 100644--- a/products/ai_observability/frontend/playground/playgroundPromptConfig.test.ts+++ b/products/ai_observability/frontend/playground/playgroundPromptConfig.test.ts@@ -3,6 +3,11 @@ import { parsePlaygroundConfig, serializePlaygroundConfig } from './playgroundPrdescribe('playgroundPromptConfig', () => {const modelConfig = { model: 'gpt-5', provider: 'openai', provider_key_id: 'key-1' }+ const responseSchema = { type: 'object', properties: { ok: { type: 'boolean' } }, required: ['ok'] }+ const responseFormat = {+ type: 'json_schema' as const,+ json_schema: { name: 'verdict', schema: responseSchema, strict: false },+ }const fullPrompt = createPromptConfig({model: 'gpt-5',selectedProviderKeyId: 'key-1',@@ -13,6 +18,7 @@ describe('playgroundPromptConfig', () => {thinking: true,reasoningLevel: 'high',tools: [{ type: 'function', function: { name: 'lookup' } }],+ responseFormat,messages: [{ role: 'user', content: 'Hi {{name}}' },{@@ -36,6 +42,7 @@ describe('playgroundPromptConfig', () => {thinking: true,reasoningLevel: 'high',tools: [{ type: 'function', function: { name: 'lookup' } }],+ responseFormat,messages: [{ role: 'user', content: 'Hi {{name}}' },{@@ -51,7 +58,7 @@ describe('playgroundPromptConfig', () => {it('round-trips a default panel without inventing values', () => {const serialized = serializePlaygroundConfig(createPromptConfig(), modelConfig, null)expect(Object.keys(serialized ?? {})).toEqual(- expect.not.arrayContaining(['temperature', 'max_tokens', 'top_p', 'tools', 'messages'])+ expect.not.arrayContaining(['temperature', 'max_tokens', 'top_p', 'tools', 'response_format', 'messages']))expect(parsePlaygroundConfig(serialized)).toMatchObject({temperature: null,@@ -60,6 +67,7 @@ describe('playgroundPromptConfig', () => {thinking: false,reasoningLevel: 'medium',tools: null,+ responseFormat: null,messages: [],})})@@ -74,6 +82,20 @@ describe('playgroundPromptConfig', () => {})})+ it.each([+ [+ 'keeps a stored format the playground cannot edit',+ { type: 'json_object' },+ createPromptConfig(),+ { type: 'json_object' },+ ],+ ['replaces it once the panel has a schema', { type: 'json_object' }, fullPrompt, responseFormat],+ ['drops a supported format the user cleared', responseFormat, createPromptConfig(), undefined],+ ])('%s when saving over an existing response format', (_, existing, prompt, expected) => {+ const serialized = serializePlaygroundConfig(prompt, modelConfig, { response_format: existing })+ expect(serialized?.response_format).toEqual(expected)+ })+it('carries the stored model selection forward when no model config is passed', () => {const existing = { model: 'gpt-5', provider: 'openai', provider_key_id: 'key-1', owner: 'api-user' }const serialized = serializePlaygroundConfig(createPromptConfig(), null, existing)@@ -111,6 +133,7 @@ describe('playgroundPromptConfig', () => {thinking: 'yes',reasoning_effort: 'extreme',tools: ['not-an-object'],+ response_format: { type: 'json_object' },messages: [{ role: 'alien', content: 'x' }, { role: 'user', content: 'ok' }, 'junk'],})expect(parsed).toEqual({@@ -123,7 +146,23 @@ describe('playgroundPromptConfig', () => {thinking: false,reasoningLevel: null,tools: null,+ responseFormat: null,messages: [{ role: 'user', content: 'ok' }],})})++ it.each([+ [+ 'fills in the name and strict flag',+ { type: 'json_schema', json_schema: { schema: responseSchema } },+ { type: 'json_schema', json_schema: { name: 'response', schema: responseSchema, strict: true } },+ ],+ [+ 'drops a format whose schema is not an object',+ { type: 'json_schema', json_schema: { schema: 'object' } },+ null,+ ],+ ])('%s when restoring a response format written outside the playground', (_, stored, expected) => {+ expect(parsePlaygroundConfig({ response_format: stored })?.responseFormat).toEqual(expected)+ })})diff --git a/products/ai_observability/frontend/playground/playgroundPromptConfig.ts b/products/ai_observability/frontend/playground/playgroundPromptConfig.tsindex 96024221a05f..521b4cc2c3ce 100644--- a/products/ai_observability/frontend/playground/playgroundPromptConfig.ts+++ b/products/ai_observability/frontend/playground/playgroundPromptConfig.ts@@ -1,6 +1,13 @@import { isObject } from 'lib/utils/guards'-import type { Message, MessageRole, MessageToolCall, PromptConfig, ReasoningLevel } from './llmPlaygroundPromptsLogic'+import type {+ Message,+ MessageRole,+ MessageToolCall,+ PlaygroundResponseFormat,+ PromptConfig,+ ReasoningLevel,+} from './llmPlaygroundPromptsLogic'export interface PlaygroundModelConfig {model: string@@ -20,12 +27,39 @@ const PLAYGROUND_CONFIG_KEYS = new Set(['thinking','reasoning_effort','tools',+ 'response_format','messages',])const MESSAGE_ROLES: MessageRole[] = ['user', 'assistant', 'system', 'tool']const REASONING_LEVELS: Exclude<ReasoningLevel, null>[] = ['minimal', 'low', 'medium', 'high']+// OpenAI requires a schema name. Providers that do not need one ignore it.+export const DEFAULT_RESPONSE_SCHEMA_NAME = 'response'++export function createResponseFormat(schema: Record<string, unknown>): PlaygroundResponseFormat {+ return { type: 'json_schema', json_schema: { name: DEFAULT_RESPONSE_SCHEMA_NAME, schema, strict: true } }+}++// Only a `json_schema` envelope is accepted, so `json_object` or a bare schema never reaches the proxy.+export function normalizeResponseFormat(value: unknown): PlaygroundResponseFormat | null {+ if (!isObject(value) || value.type !== 'json_schema' || !isObject(value.json_schema)) {+ return null+ }+ const { name, schema, strict } = value.json_schema+ if (!isObject(schema)) {+ return null+ }+ return {+ type: 'json_schema',+ json_schema: {+ name: typeof name === 'string' && name ? name : DEFAULT_RESPONSE_SCHEMA_NAME,+ schema,+ strict: typeof strict === 'boolean' ? strict : true,+ },+ }+}+export interface ParsedPlaygroundConfig {model: string | nullprovider: string | null@@ -36,13 +70,15 @@ export interface ParsedPlaygroundConfig {thinking: booleanreasoningLevel: ReasoningLeveltools: Record<string, unknown>[] | null+ responseFormat: PlaygroundResponseFormat | nullmessages: Message[]}/*** Builds the config payload to store with a prompt version: the playground's model settings,- * tools, and conversation messages, merged over any non-playground keys already in the- * version's config. Variable placeholders in message content are stored raw, never substituted.+ * tools, response format, and conversation messages, merged over any non-playground keys+ * already in the version's config. Variable placeholders in message content are stored raw,+ * never substituted.* Returns null when there is nothing to store, so the version's config stays null.*/export function serializePlaygroundConfig(@@ -88,6 +124,17 @@ export function serializePlaygroundConfig(if (prompt.tools && prompt.tools.length > 0) {config.tools = prompt.tools}+ if (prompt.responseFormat) {+ config.response_format = prompt.responseFormat+ } else if (+ isObject(existingConfig) &&+ isObject(existingConfig.response_format) &&+ normalizeResponseFormat(existingConfig.response_format) === null+ ) {+ // A format the playground cannot edit (such as `json_object`) never reached the panel,+ // so the panel being empty is not the user clearing it. Keep it for SDK consumers.+ config.response_format = existingConfig.response_format+ }if (prompt.messages.length > 0) {config.messages = prompt.messages.map((message) => ({role: message.role,@@ -173,6 +220,7 @@ export function parsePlaygroundConfig(config: unknown): ParsedPlaygroundConfig |? (REASONING_LEVELS.find((level) => level === config.reasoning_effort) ?? null): 'medium',tools,+ responseFormat: normalizeResponseFormat(config.response_format),messages,}}