Skip to content

Commit 6fb9bb5

Browse files
authored
Bugfix/Gsuite tool params (#5189)
* fix gsuite tool params * custom assistant only check for mandatory fields for visible params * azure chat openai fix for gpt5 * return raw from executeJavaScriptCode * add json5 for parsing * azure chatopenai use maxCompletionTokens
1 parent 32bf030 commit 6fb9bb5

File tree

19 files changed

+539
-734
lines changed

19 files changed

+539
-734
lines changed

packages/components/nodes/agentflow/Agent/Agent.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,9 +1723,20 @@ class Agent_Agentflow implements INode {
17231723
}
17241724

17251725
console.error('Error invoking tool:', e)
1726+
const errMsg = getErrorMessage(e)
1727+
let toolInput = toolCall.args
1728+
if (typeof errMsg === 'string' && errMsg.includes(TOOL_ARGS_PREFIX)) {
1729+
const [_, args] = errMsg.split(TOOL_ARGS_PREFIX)
1730+
try {
1731+
toolInput = JSON.parse(args)
1732+
} catch (e) {
1733+
console.error('Error parsing tool input from tool:', e)
1734+
}
1735+
}
1736+
17261737
usedTools.push({
17271738
tool: selectedTool.name,
1728-
toolInput: toolCall.args,
1739+
toolInput,
17291740
toolOutput: '',
17301741
error: getErrorMessage(e)
17311742
})
@@ -1995,9 +2006,20 @@ class Agent_Agentflow implements INode {
19952006
}
19962007

19972008
console.error('Error invoking tool:', e)
2009+
const errMsg = getErrorMessage(e)
2010+
let toolInput = toolCall.args
2011+
if (typeof errMsg === 'string' && errMsg.includes(TOOL_ARGS_PREFIX)) {
2012+
const [_, args] = errMsg.split(TOOL_ARGS_PREFIX)
2013+
try {
2014+
toolInput = JSON.parse(args)
2015+
} catch (e) {
2016+
console.error('Error parsing tool input from tool:', e)
2017+
}
2018+
}
2019+
19982020
usedTools.push({
19992021
tool: selectedTool.name,
2000-
toolInput: toolCall.args,
2022+
toolInput,
20012023
toolOutput: '',
20022024
error: getErrorMessage(e)
20032025
})

packages/components/nodes/chatmodels/AzureChatOpenAI/AzureChatOpenAI.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,9 @@ class AzureChatOpenAI_ChatModels implements INode {
273273
console.error('Error parsing base options', exception)
274274
}
275275
}
276-
if (modelName === 'o3-mini' || modelName.includes('o1')) {
276+
if (modelName.includes('o1') || modelName.includes('o3') || modelName.includes('gpt-5')) {
277277
delete obj.temperature
278-
}
279-
if (modelName.includes('o1') || modelName.includes('o3')) {
278+
delete obj.stop
280279
const reasoning: OpenAIClient.Reasoning = {}
281280
if (reasoningEffort) {
282281
reasoning.effort = reasoningEffort
@@ -285,6 +284,11 @@ class AzureChatOpenAI_ChatModels implements INode {
285284
reasoning.summary = reasoningSummary
286285
}
287286
obj.reasoning = reasoning
287+
288+
if (maxTokens) {
289+
delete obj.maxTokens
290+
obj.maxCompletionTokens = parseInt(maxTokens, 10)
291+
}
288292
}
289293

290294
const multiModalOption: IMultiModalOption = {

packages/components/nodes/tools/AgentAsTool/AgentAsTool.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,15 @@ try {
362362

363363
const sandbox = createCodeExecutionSandbox('', [], {}, additionalSandbox)
364364

365-
const response = await executeJavaScriptCode(code, sandbox, {
365+
let response = await executeJavaScriptCode(code, sandbox, {
366366
useSandbox: false,
367367
timeout: 10000
368368
})
369369

370+
if (typeof response === 'object') {
371+
response = JSON.stringify(response)
372+
}
373+
370374
return response
371375
}
372376
}

packages/components/nodes/tools/ChatflowTool/ChatflowTool.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,15 @@ try {
370370

371371
const sandbox = createCodeExecutionSandbox('', [], {}, additionalSandbox)
372372

373-
const response = await executeJavaScriptCode(code, sandbox, {
373+
let response = await executeJavaScriptCode(code, sandbox, {
374374
useSandbox: false,
375375
timeout: 10000
376376
})
377377

378+
if (typeof response === 'object') {
379+
response = JSON.stringify(response)
380+
}
381+
378382
return response
379383
}
380384
}

packages/components/nodes/tools/CustomTool/core.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ export class DynamicStructuredTool<
124124

125125
const sandbox = createCodeExecutionSandbox('', this.variables || [], flow, additionalSandbox)
126126

127-
const response = await executeJavaScriptCode(this.code, sandbox, {
127+
let response = await executeJavaScriptCode(this.code, sandbox, {
128128
timeout: 10000
129129
})
130130

131+
if (typeof response === 'object') {
132+
response = JSON.stringify(response)
133+
}
134+
131135
return response
132136
}
133137

0 commit comments

Comments
 (0)