Skip to content

Commit df0add6

Browse files
committed
fix(n8n): add debug logging for tool call args [skip ci]
1 parent c49c335 commit df0add6

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

n8n-node/nodes/TruseraAgent/TruseraAgent.node.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ export class TruseraAgent implements INodeType {
194194

195195
const connectedTools = Array.isArray(rawTools) ? rawTools : [rawTools].filter(Boolean);
196196

197+
// Debug: log tool details
198+
for (const tool of connectedTools) {
199+
console.log(`[TruseraAgent] Connected tool: ${tool.name}, type: ${tool.constructor?.name}, hasSchema: ${!!tool.schema}, schemaShape: ${tool.schema?.shape ? Object.keys(tool.schema.shape).join(',') : 'none'}`);
200+
}
201+
197202
// Bind tools to the model — pass tool objects directly.
198203
// LangChain's bindTools() handles schema extraction internally.
199204
const modelWithTools = model.bindTools
@@ -238,9 +243,17 @@ export class TruseraAgent implements INodeType {
238243
for (const toolCall of toolCalls) {
239244
const toolName = toolCall.name ?? toolCall.function?.name ?? 'unknown';
240245
const toolArgsRaw = toolCall.args ?? toolCall.function?.arguments ?? '{}';
241-
const toolArgs = typeof toolArgsRaw === 'string' ? JSON.parse(toolArgsRaw) : toolArgsRaw;
246+
let toolArgs: Record<string, unknown>;
247+
try {
248+
toolArgs = typeof toolArgsRaw === 'string' ? JSON.parse(toolArgsRaw) : (toolArgsRaw ?? {});
249+
} catch {
250+
toolArgs = { raw: String(toolArgsRaw) };
251+
}
242252
const callId = toolCall.id ?? `call_${iter}`;
243253

254+
// Debug: log tool call details
255+
console.log(`[TruseraAgent] Tool call: ${toolName}, args keys: ${Object.keys(toolArgs).join(',')}, args: ${JSON.stringify(toolArgs).slice(0, 200)}`);
256+
244257
// ── THE KEY: Policy evaluation BEFORE tool execution ──
245258
const proposal: ToolCallProposal = {
246259
toolName,

0 commit comments

Comments
 (0)