Skip to content

Commit b191a54

Browse files
committed
fix(langsmith): align get_run/update_run outputs and narrow feedback score type
- get_run now also outputs runId (alias of id) so workflows can read the run identifier consistently across all operations on the block - update_run now parses and surfaces the response message instead of discarding the body entirely, matching create_run's pattern - narrow LangsmithCreateFeedbackParams.score to number — the tool param is declared as JSON-schema 'number' and the block's parseScore never produces a boolean, so the wider type was dead and misleading
1 parent 8c915c0 commit b191a54

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

apps/sim/tools/langsmith/create_feedback.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const langsmithCreateFeedbackTool: ToolConfig<
3737
type: 'number',
3838
required: false,
3939
visibility: 'user-or-llm',
40-
description: 'Numeric or boolean score for the feedback metric',
40+
description: 'Numeric score for the feedback metric',
4141
},
4242
value: {
4343
type: 'string',
@@ -102,7 +102,7 @@ export const langsmithCreateFeedbackTool: ToolConfig<
102102
id: data.id as string,
103103
key: data.key as string,
104104
runId: (data.run_id as string) ?? null,
105-
score: (data.score as number | boolean) ?? null,
105+
score: (data.score as number) ?? null,
106106
value: (data.value as string | number | boolean) ?? null,
107107
comment: (data.comment as string) ?? null,
108108
createdAt: (data.created_at as string) ?? null,

apps/sim/tools/langsmith/get_run.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const langsmithGetRunTool: ToolConfig<LangsmithGetRunParams, LangsmithGet
3939
success: true,
4040
output: {
4141
id: data.id as string,
42+
runId: data.id as string,
4243
name: data.name as string,
4344
runType: data.run_type as string,
4445
status: (data.status as string) ?? null,
@@ -58,6 +59,10 @@ export const langsmithGetRunTool: ToolConfig<LangsmithGetRunParams, LangsmithGet
5859
},
5960
outputs: {
6061
id: { type: 'string', description: 'Run ID' },
62+
runId: {
63+
type: 'string',
64+
description: 'Run ID (alias of id, for consistency with other operations)',
65+
},
6166
name: { type: 'string', description: 'Run name' },
6267
runType: {
6368
type: 'string',

apps/sim/tools/langsmith/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface LangsmithUpdateRunResponse extends ToolResponse {
7474
output: {
7575
accepted: boolean
7676
runId: string
77+
message: string | null
7778
}
7879
}
7980

@@ -85,6 +86,7 @@ export interface LangsmithGetRunParams {
8586
export interface LangsmithGetRunResponse extends ToolResponse {
8687
output: {
8788
id: string
89+
runId: string
8890
name: string
8991
runType: string
9092
status: string | null
@@ -108,7 +110,7 @@ export interface LangsmithCreateFeedbackParams {
108110
apiKey: string
109111
runId: string
110112
key: string
111-
score?: number | boolean
113+
score?: number
112114
value?: string
113115
comment?: string
114116
correction?: Record<string, unknown>
@@ -120,7 +122,7 @@ export interface LangsmithCreateFeedbackResponse extends ToolResponse {
120122
id: string
121123
key: string
122124
runId: string | null
123-
score: number | boolean | null
125+
score: number | null
124126
value: string | number | boolean | null
125127
comment: string | null
126128
createdAt: string | null

apps/sim/tools/langsmith/update_run.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,23 @@ export const langsmithUpdateRunTool: ToolConfig<
100100
throw new Error(`LangSmith update run failed (${response.status}): ${errorText}`)
101101
}
102102

103+
const responseText = await response.text()
104+
let message: string | null = null
105+
if (responseText) {
106+
try {
107+
const data = JSON.parse(responseText) as Record<string, unknown>
108+
message = typeof data.message === 'string' ? data.message : null
109+
} catch {
110+
// Response body isn't JSON (e.g. empty object or plain text) — no message to surface
111+
}
112+
}
113+
103114
return {
104115
success: true,
105116
output: {
106117
accepted: true,
107118
runId: params?.runId.trim() ?? '',
119+
message,
108120
},
109121
}
110122
},
@@ -117,5 +129,10 @@ export const langsmithUpdateRunTool: ToolConfig<
117129
type: 'string',
118130
description: 'ID of the run that was updated',
119131
},
132+
message: {
133+
type: 'string',
134+
description: 'Response message from LangSmith, if provided',
135+
optional: true,
136+
},
120137
},
121138
}

0 commit comments

Comments
 (0)