Skip to content

Commit 4ffacae

Browse files
committed
fix(youcom): unique subblock ids, nullable outputs, reject non-array contents
1 parent 79ac337 commit 4ffacae

9 files changed

Lines changed: 86 additions & 67 deletions

File tree

‎apps/sim/blocks/blocks/youcom.ts‎

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ const ANSWER_LANGUAGE_OPTIONS = [
102102
{ label: 'Vietnamese', id: 'VI' },
103103
]
104104

105+
const ANSWER_LANGUAGE_IDS = new Set(
106+
ANSWER_LANGUAGE_OPTIONS.map((option) => option.id).filter((id) => id !== '')
107+
)
108+
105109
const SEARCH_ONLY_LANGUAGES = [
106110
{ label: 'Chinese (Simplified)', id: 'ZH-HANS' },
107111
{ label: 'Chinese (Traditional)', id: 'ZH-HANT' },
@@ -159,14 +163,16 @@ export const YouComBlock: BlockConfig = {
159163
{ text: ', within', field: 'includeDomains' },
160164
],
161165
[GET_CONTENTS]: [{ text: 'Read page contents from', field: 'urls', core: true }],
162-
[ANSWER]: [{ text: 'Answer', field: 'query', after: 'with cited sources', core: true }],
166+
[ANSWER]: [{ text: 'Answer', field: 'question', after: 'with cited sources', core: true }],
163167
[RESEARCH]: [
164168
{ text: 'Research', field: 'input', core: true },
165169
{ text: 'at', field: 'researchEffort', after: 'effort' },
166170
],
167171
[GET_RESEARCH_TASK]: [{ text: 'Check research task', field: 'taskId', core: true }],
168-
[FINANCE_RESEARCH]: [{ text: 'Research financial question', field: 'input', core: true }],
169-
[SEARCH_IMAGES]: [{ text: 'Find images of', field: 'query', core: true }],
172+
[FINANCE_RESEARCH]: [
173+
{ text: 'Research financial question', field: 'financeInput', core: true },
174+
],
175+
[SEARCH_IMAGES]: [{ text: 'Find images of', field: 'imageQuery', core: true }],
170176
[GET_ACCOUNT_BALANCE]: ['Get remaining API credit balance'],
171177
},
172178
},
@@ -197,15 +203,15 @@ export const YouComBlock: BlockConfig = {
197203
required: true,
198204
},
199205
{
200-
id: 'query',
206+
id: 'question',
201207
title: 'Question',
202208
type: 'long-input',
203209
placeholder: 'Enter your question',
204210
condition: { field: 'operation', value: ANSWER },
205211
required: true,
206212
},
207213
{
208-
id: 'query',
214+
id: 'imageQuery',
209215
title: 'Image Query',
210216
type: 'long-input',
211217
placeholder: 'Enter what to find images of (supports site: and filetype:)',
@@ -342,7 +348,7 @@ export const YouComBlock: BlockConfig = {
342348
required: true,
343349
},
344350
{
345-
id: 'input',
351+
id: 'financeInput',
346352
title: 'Financial Question',
347353
type: 'long-input',
348354
placeholder: 'e.g., What drove NVIDIA revenue growth in fiscal 2025?',
@@ -504,10 +510,17 @@ export const YouComBlock: BlockConfig = {
504510
const maxAge = toOptionalNumber(params.maxAge)
505511
if (maxAge !== undefined) result.maxAge = maxAge
506512

507-
// Hidden advanced fields still serialize; keep Search-only languages (JA) out of Answer
508-
if (params.operation === ANSWER) result.language = params.answerLanguage || undefined
509-
if (params.operation === FINANCE_RESEARCH && params.financeResearchEffort) {
510-
result.researchEffort = params.financeResearchEffort
513+
// Agent tool calls run this over LLM args too, so fall back to the tool param names
514+
if (params.operation === ANSWER) {
515+
result.query = params.question ?? params.query
516+
// Hidden advanced fields still serialize; keep Search-only languages (JA) out of Answer
517+
const language = params.answerLanguage || params.language
518+
result.language = ANSWER_LANGUAGE_IDS.has(language) ? language : undefined
519+
}
520+
if (params.operation === SEARCH_IMAGES) result.query = params.imageQuery ?? params.query
521+
if (params.operation === FINANCE_RESEARCH) {
522+
result.input = params.financeInput ?? params.input
523+
if (params.financeResearchEffort) result.researchEffort = params.financeResearchEffort
511524
}
512525
const effort = result.researchEffort ?? params.researchEffort
513526
const isSyncResearch =
@@ -522,14 +535,17 @@ export const YouComBlock: BlockConfig = {
522535
inputs: {
523536
operation: { type: 'string', description: 'Operation to perform' },
524537
apiKey: { type: 'string', description: 'You.com API key' },
525-
query: { type: 'string', description: 'Search query, question, or image query' },
538+
query: { type: 'string', description: 'Search query' },
539+
question: { type: 'string', description: 'Question to answer' },
540+
imageQuery: { type: 'string', description: 'Image search query' },
526541
extractionMode: { type: 'string', description: 'Per-result content: highlights or full_page' },
527542
extractionFormats: { type: 'json', description: 'Full page formats: markdown, html' },
528543
extractionSource: { type: 'string', description: 'Full page source: blend, cache, or fetch' },
529544
urls: { type: 'string', description: 'Comma-separated URLs to fetch' },
530545
formats: { type: 'json', description: 'Content formats: markdown, html, metadata' },
531546
maxAge: { type: 'number', description: 'Maximum cached content age in seconds' },
532-
input: { type: 'string', description: 'Research or financial research question' },
547+
input: { type: 'string', description: 'Research question' },
548+
financeInput: { type: 'string', description: 'Financial research question' },
533549
researchEffort: { type: 'string', description: 'Research effort level' },
534550
outputSchema: { type: 'json', description: 'JSON Schema for structured research output' },
535551
background: { type: 'boolean', description: 'Run research as a background task' },

‎apps/sim/tools/generated/tool-outputs.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/youcom/answer.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ export const youComAnswerTool: ToolConfig<YouComAnswerParams, YouComAnswerRespon
153153
description: 'Text snippets previewing the content',
154154
items: { type: 'string' },
155155
},
156-
description: { type: 'string', description: 'Brief description', optional: true },
157-
thumbnailUrl: { type: 'string', description: 'Thumbnail URL', optional: true },
158-
pageAge: { type: 'string', description: 'Age of the result', optional: true },
156+
description: { type: 'string', description: 'Brief description', nullable: true },
157+
thumbnailUrl: { type: 'string', description: 'Thumbnail URL', nullable: true },
158+
pageAge: { type: 'string', description: 'Age of the result', nullable: true },
159159
},
160160
},
161161
},

‎apps/sim/tools/youcom/get_contents.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { toStringOrNull } from '@sim/utils/coerce'
2-
import { toArray, toRecordOrNull } from '@sim/utils/object'
2+
import { toRecordOrNull } from '@sim/utils/object'
33
import type { ToolConfig } from '@/tools/types'
44
import type { YouComGetContentsParams, YouComGetContentsResponse } from '@/tools/youcom/types'
55
import {
@@ -69,11 +69,14 @@ export const youComGetContentsTool: ToolConfig<YouComGetContentsParams, YouComGe
6969

7070
transformResponse: async (response: Response) => {
7171
const data = await response.json()
72+
if (!Array.isArray(data)) {
73+
throw new Error('Unexpected You.com Contents response: expected an array of pages')
74+
}
7275

7376
return {
7477
success: true,
7578
output: {
76-
pages: toArray(data).map((item) => {
79+
pages: data.map((item) => {
7780
const page = toRecordOrNull(item) ?? {}
7881
const metadata = toRecordOrNull(page.metadata) ?? {}
7982
return {
@@ -96,23 +99,23 @@ export const youComGetContentsTool: ToolConfig<YouComGetContentsParams, YouComGe
9699
items: {
97100
type: 'object',
98101
properties: {
99-
url: { type: 'string', description: 'URL of the fetched page', optional: true },
100-
title: { type: 'string', description: 'Title of the page', optional: true },
101-
html: { type: 'string', description: 'Page HTML (html format)', optional: true },
102+
url: { type: 'string', description: 'URL of the fetched page', nullable: true },
103+
title: { type: 'string', description: 'Title of the page', nullable: true },
104+
html: { type: 'string', description: 'Page HTML (html format)', nullable: true },
102105
markdown: {
103106
type: 'string',
104107
description: 'Page Markdown (markdown format)',
105-
optional: true,
108+
nullable: true,
106109
},
107110
siteName: {
108111
type: 'string',
109112
description: 'OpenGraph site name (metadata format)',
110-
optional: true,
113+
nullable: true,
111114
},
112115
faviconUrl: {
113116
type: 'string',
114117
description: "Favicon URL of the page's domain (metadata format)",
115-
optional: true,
118+
nullable: true,
116119
},
117120
},
118121
},

‎apps/sim/tools/youcom/get_research_task.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,41 +89,41 @@ export const youComGetResearchTaskTool: ToolConfig<
8989
updatedAt: {
9090
type: 'string',
9191
description: 'When the task was last updated, RFC 3339',
92-
optional: true,
92+
nullable: true,
9393
},
9494
completedAt: {
9595
type: 'string',
9696
description: 'When the task reached a terminal status, RFC 3339',
97-
optional: true,
97+
nullable: true,
9898
},
99-
error: { type: 'string', description: 'Diagnostic message when failed', optional: true },
99+
error: { type: 'string', description: 'Diagnostic message when failed', nullable: true },
100100
taskInput: {
101101
type: 'json',
102102
description: 'Original request parameters submitted for the task',
103-
optional: true,
103+
nullable: true,
104104
properties: {
105105
input: { type: 'string', description: 'Research question that was submitted' },
106106
researchEffort: { type: 'string', description: 'Research effort level submitted' },
107107
background: { type: 'boolean', description: 'Whether background mode was requested' },
108108
outputSchema: {
109109
type: 'json',
110110
description: 'Structured output schema submitted',
111-
optional: true,
111+
nullable: true,
112112
},
113113
sourceControl: {
114114
type: 'json',
115115
description: 'Source control configuration submitted',
116-
optional: true,
116+
nullable: true,
117117
},
118118
type: { type: 'string', description: 'Task type (research)' },
119119
},
120120
},
121121
content: {
122122
...RESEARCH_CONTENT_OUTPUT,
123123
description: `${RESEARCH_CONTENT_OUTPUT.description} (completed only)`,
124-
optional: true,
124+
nullable: true,
125125
},
126-
contentType: { ...RESEARCH_CONTENT_TYPE_OUTPUT, optional: true },
126+
contentType: { ...RESEARCH_CONTENT_TYPE_OUTPUT, nullable: true },
127127
sources: RESEARCH_SOURCES_OUTPUT,
128128
warnings: RESEARCH_WARNINGS_OUTPUT,
129129
},

‎apps/sim/tools/youcom/research.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,30 +130,30 @@ export const youComResearchTool: ToolConfig<YouComResearchParams, YouComResearch
130130
},
131131

132132
outputs: {
133-
content: { ...RESEARCH_CONTENT_OUTPUT, optional: true },
134-
contentType: { ...RESEARCH_CONTENT_TYPE_OUTPUT, optional: true },
133+
content: { ...RESEARCH_CONTENT_OUTPUT, nullable: true },
134+
contentType: { ...RESEARCH_CONTENT_TYPE_OUTPUT, nullable: true },
135135
sources: RESEARCH_SOURCES_OUTPUT,
136136
warnings: RESEARCH_WARNINGS_OUTPUT,
137137
taskId: {
138138
type: 'string',
139139
description: 'Background task ID to pass to Get Research Task (background only)',
140-
optional: true,
140+
nullable: true,
141141
},
142142
status: {
143143
type: 'string',
144144
description:
145145
'Background task status: queued, running, completed, failed, or cancelled (background only)',
146-
optional: true,
146+
nullable: true,
147147
},
148148
streamUrl: {
149149
type: 'string',
150150
description: 'URL path of the task progress event stream (background only)',
151-
optional: true,
151+
nullable: true,
152152
},
153153
createdAt: {
154154
type: 'string',
155155
description: 'When the background task was created, RFC 3339 (background only)',
156-
optional: true,
156+
nullable: true,
157157
},
158158
},
159159
}

‎apps/sim/tools/youcom/search.ts‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -218,36 +218,36 @@ export const youComSearchTool: ToolConfig<YouComSearchParams, YouComSearchRespon
218218
items: {
219219
type: 'object',
220220
properties: {
221-
url: { type: 'string', description: 'URL of the result', optional: true },
222-
title: { type: 'string', description: 'Title of the result', optional: true },
221+
url: { type: 'string', description: 'URL of the result', nullable: true },
222+
title: { type: 'string', description: 'Title of the result', nullable: true },
223223
description: {
224224
type: 'string',
225225
description: 'Brief description of the result',
226-
optional: true,
226+
nullable: true,
227227
},
228228
snippets: {
229229
type: 'array',
230230
description:
231231
'Short keyword-centered fragments (omitted when highlights extraction is used)',
232232
items: { type: 'string' },
233233
},
234-
thumbnailUrl: { type: 'string', description: 'Thumbnail URL', optional: true },
234+
thumbnailUrl: { type: 'string', description: 'Thumbnail URL', nullable: true },
235235
faviconUrl: {
236236
type: 'string',
237237
description: "Favicon URL of the result's domain",
238-
optional: true,
238+
nullable: true,
239239
},
240-
pageAge: { type: 'string', description: 'Age of the result', optional: true },
240+
pageAge: { type: 'string', description: 'Age of the result', nullable: true },
241241
highlights: {
242242
type: 'array',
243243
description: 'Query-relevant passages (highlights extraction only)',
244244
items: { type: 'string' },
245245
},
246-
html: { type: 'string', description: 'Full page HTML (full_page only)', optional: true },
246+
html: { type: 'string', description: 'Full page HTML (full_page only)', nullable: true },
247247
markdown: {
248248
type: 'string',
249249
description: 'Full page Markdown (full_page only)',
250-
optional: true,
250+
nullable: true,
251251
},
252252
},
253253
},
@@ -258,20 +258,20 @@ export const youComSearchTool: ToolConfig<YouComSearchParams, YouComSearchRespon
258258
items: {
259259
type: 'object',
260260
properties: {
261-
url: { type: 'string', description: 'URL of the article', optional: true },
262-
title: { type: 'string', description: 'Title of the article', optional: true },
261+
url: { type: 'string', description: 'URL of the article', nullable: true },
262+
title: { type: 'string', description: 'Title of the article', nullable: true },
263263
description: {
264264
type: 'string',
265265
description: 'Brief description of the article',
266-
optional: true,
266+
nullable: true,
267267
},
268-
thumbnailUrl: { type: 'string', description: 'Thumbnail URL', optional: true },
269-
pageAge: { type: 'string', description: 'UTC publication timestamp', optional: true },
270-
html: { type: 'string', description: 'Full page HTML (full_page only)', optional: true },
268+
thumbnailUrl: { type: 'string', description: 'Thumbnail URL', nullable: true },
269+
pageAge: { type: 'string', description: 'UTC publication timestamp', nullable: true },
270+
html: { type: 'string', description: 'Full page HTML (full_page only)', nullable: true },
271271
markdown: {
272272
type: 'string',
273273
description: 'Full page Markdown (full_page only)',
274-
optional: true,
274+
nullable: true,
275275
},
276276
},
277277
},
@@ -287,12 +287,12 @@ export const youComSearchTool: ToolConfig<YouComSearchParams, YouComSearchRespon
287287
description: {
288288
type: 'string',
289289
description: 'Knowledge drawn from licensed data',
290-
optional: true,
290+
nullable: true,
291291
},
292292
asOf: {
293293
type: 'string',
294294
description: 'Date the data covers (YYYY-MM-DD)',
295-
optional: true,
295+
nullable: true,
296296
},
297297
attribution: {
298298
type: 'array',
@@ -304,16 +304,16 @@ export const youComSearchTool: ToolConfig<YouComSearchParams, YouComSearchRespon
304304
sourceDescription: {
305305
type: 'string',
306306
description: 'Description of the provider',
307-
optional: true,
307+
nullable: true,
308308
},
309309
},
310310
},
311311
},
312312
},
313313
},
314314
},
315-
searchUuid: { type: 'string', description: 'Unique ID of the search', optional: true },
316-
query: { type: 'string', description: 'Query used to retrieve the results', optional: true },
317-
latency: { type: 'number', description: 'Search latency in seconds', optional: true },
315+
searchUuid: { type: 'string', description: 'Unique ID of the search', nullable: true },
316+
query: { type: 'string', description: 'Query used to retrieve the results', nullable: true },
317+
latency: { type: 'number', description: 'Search latency in seconds', nullable: true },
318318
},
319319
}

‎apps/sim/tools/youcom/search_images.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,23 @@ export const youComSearchImagesTool: ToolConfig<
7878
items: {
7979
type: 'object',
8080
properties: {
81-
title: { type: 'string', description: 'Title of the image result', optional: true },
81+
title: { type: 'string', description: 'Title of the image result', nullable: true },
8282
pageUrl: {
8383
type: 'string',
8484
description: 'URL of the page containing the image',
85-
optional: true,
85+
nullable: true,
8686
},
87-
imageUrl: { type: 'string', description: 'Direct URL to the image', optional: true },
88-
thumbnail: { type: 'string', description: 'Proxy-hosted thumbnail URL', optional: true },
87+
imageUrl: { type: 'string', description: 'Direct URL to the image', nullable: true },
88+
thumbnail: { type: 'string', description: 'Proxy-hosted thumbnail URL', nullable: true },
8989
largeThumbnail: {
9090
type: 'string',
9191
description: 'Larger resized image URL; fall back to thumbnail or imageUrl if it fails',
92-
optional: true,
92+
nullable: true,
9393
},
9494
},
9595
},
9696
},
97-
query: { type: 'string', description: 'Query that was submitted', optional: true },
98-
searchUuid: { type: 'string', description: 'Unique ID of the search', optional: true },
97+
query: { type: 'string', description: 'Query that was submitted', nullable: true },
98+
searchUuid: { type: 'string', description: 'Unique ID of the search', nullable: true },
9999
},
100100
}

0 commit comments

Comments
 (0)