Skip to content

fix: Add missing chat tool input logs#26229

Merged
michael-radency merged 4 commits intomasterfrom
node-4514-fix-chat-tool-input-in-logs
Feb 25, 2026
Merged

fix: Add missing chat tool input logs#26229
michael-radency merged 4 commits intomasterfrom
node-4514-fix-chat-tool-input-in-logs

Conversation

@michael-radency
Copy link
Contributor

Summary

fixes issue when input logs was not displayed for chat tool
image
image

Related Linear tickets, Github issues, and Community forum posts

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@michael-radency michael-radency added the n8n team Authored by the n8n team label Feb 25, 2026
@Joffcom Joffcom requested a review from dlavrenuek February 25, 2026 09:59
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/cli/src/chat/chat-execution-manager.ts">

<violation number="1" location="packages/cli/src/chat/chat-execution-manager.ts:148">
P1: Custom agent: **Tests**

Community PR Guidelines (Testing Requirements) require PRs to include tests. This change adds new execution/logging behavior for chat tool runs, but no tests are included in the PR diff to cover the updated behavior.</violation>

<violation number="2" location="packages/cli/src/chat/chat-execution-manager.ts:148">
P3: This block duplicates the inputOverride preservation and runData popping logic already implemented in `waiting-webhooks.ts`. Consider extracting the shared logic into a helper to avoid divergence when this behavior changes.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant UI as Chat UI
    participant CEM as ChatExecutionManager
    participant State as Execution State
    participant Ownership as OwnershipService
    participant Runner as WorkflowRunner

    Note over UI,Runner: Runtime Flow: Resuming Chat with Tool Input

    UI->>CEM: sendMessage(message)
    
    CEM->>State: Inspect top of nodeExecutionStack
    
    alt NEW: Node is CHAT_TOOL_NODE_TYPE
        CEM->>State: NEW: Clear waitTill (set to undefined)
        CEM->>State: NEW: Disable node for resume
        CEM->>State: NEW: Set rewireOutputLogTo = "AiTool"
        
        opt Run Data exists for last node
            CEM->>State: Pop last execution entry from runData
            
            opt CHANGED: Entry has inputOverride
                Note right of CEM: Preserves tool input visibility<br/>for the UI logs
                CEM->>State: NEW: Push placeholder entry with preserved inputOverride
            end
        end
    end

    CEM->>Ownership: getWorkflowProjectCached(workflowId)
    Ownership-->>CEM: Project details
    
    CEM->>Runner: runNode(executionData)
    Note over Runner: Workflow resumes execution
    Runner-->>UI: Return updated chat state/logs
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

[{ json: message }],
];

if (runExecutionData.executionData!.nodeExecutionStack[0].node.type === CHAT_TOOL_NODE_TYPE) {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Custom agent: Tests

Community PR Guidelines (Testing Requirements) require PRs to include tests. This change adds new execution/logging behavior for chat tool runs, but no tests are included in the PR diff to cover the updated behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/cli/src/chat/chat-execution-manager.ts, line 148:

<comment>Community PR Guidelines (Testing Requirements) require PRs to include tests. This change adds new execution/logging behavior for chat tool runs, but no tests are included in the PR diff to cover the updated behavior.</comment>

<file context>
@@ -139,6 +145,31 @@ export class ChatExecutionManager {
 			[{ json: message }],
 		];
 
+		if (runExecutionData.executionData!.nodeExecutionStack[0].node.type === CHAT_TOOL_NODE_TYPE) {
+			runExecutionData.waitTill = undefined;
+			runExecutionData.executionData!.nodeExecutionStack[0].node.disabled = true;
</file context>
Fix with Cubic

Comment on lines +157 to +160
const entryToPop = runDataArray[runDataArray.length - 1];
// Preserve inputOverride so the LLM's input stays visible in logs after resume.
const preservedInputOverride = entryToPop?.inputOverride;
runDataArray.pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simple use pop to retrieve the element and remove it from the array.

Suggested change
const entryToPop = runDataArray[runDataArray.length - 1];
// Preserve inputOverride so the LLM's input stays visible in logs after resume.
const preservedInputOverride = entryToPop?.inputOverride;
runDataArray.pop();
const entryToPop = runDataArray.pop();
// Preserve inputOverride so the LLM's input stays visible in logs after resume.
const preservedInputOverride = entryToPop?.inputOverride;

Can runDataArray actually have undefined as an entry? If not then .pop() can not return undefined here doe to the outer check if (runDataArray?.length > 0) {, which is not recognized by TS apparently, so instead of optional checks like entryToPop?.inputOverride; you could also do const entryToPop = runDataArray.pop()!; (with !) which will ensure that this entry is not undefined also for TS (it will throw an error if it's undefined afaik).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @dlavrenuek , updated as suggested

Copy link
Contributor

@dlavrenuek dlavrenuek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected 🚀

@michael-radency michael-radency added this pull request to the merge queue Feb 25, 2026
Merged via the queue into master with commit c3ddc49 Feb 25, 2026
50 checks passed
@michael-radency michael-radency deleted the node-4514-fix-chat-tool-input-in-logs branch February 25, 2026 14:13
@n8n-assistant n8n-assistant bot mentioned this pull request Mar 2, 2026
Tuukkaa pushed a commit that referenced this pull request Mar 2, 2026
This was referenced Mar 3, 2026
@n8n-assistant
Copy link
Contributor

n8n-assistant bot commented Mar 3, 2026

Got released with [email protected]

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

n8n team Authored by the n8n team Released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants