Skip to content

fix(core): Generate title once there's enough user context#28721

Merged
Cadiac merged 1 commit into
masterfrom
instance-ai-title-generation-once-enough-context
Apr 21, 2026
Merged

fix(core): Generate title once there's enough user context#28721
Cadiac merged 1 commit into
masterfrom
instance-ai-title-generation-once-enough-context

Conversation

@Cadiac
Copy link
Copy Markdown
Contributor

@Cadiac Cadiac commented Apr 20, 2026

Summary

Makes us generate the title only after we have a bit of context - so if user sends message "hey", the title isn't immediately generated, but then on the second message once a bit of user context exists the title generation happens.

This should make the titles a bit more accurate, and we can later tune what is considered a trivial message.

Related Linear tickets, Github issues, and Community forum posts

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

Copy link
Copy Markdown
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.

No issues found across 3 files

Architecture diagram
sequenceDiagram
    participant Service as InstanceAiService
    participant Memory as Conversation Memory
    participant TitleGen as Title Generation Logic
    participant LLM as LLM Provider
    participant DB as Thread Metadata

    Note over Service,DB: Title Generation Flow (Post-Message)

    Service->>DB: Check if titleRefined is true
    opt Title not yet refined
        Service->>Memory: recall(threadId, last 5 messages)
        Memory-->>Service: Message list

        Service->>Service: CHANGED: Concat all user messages into single string
        
        alt No user messages found
            Service-->>Service: Abort
        else User text exists
            Service->>TitleGen: generateTitleFromMessage(combinedText)
            
            TitleGen->>TitleGen: isTrivialMessage(text)
            
            alt NEW: Message is trivial (e.g. "hey", "hi there")
                TitleGen-->>Service: Return null
                Note right of TitleGen: Defer generation until more context
            else Message has substance
                TitleGen->>LLM: generateText()
                LLM-->>TitleGen: Refined Title
                TitleGen-->>Service: Return Title
                
                Service->>DB: Update title and set titleRefined: true
            end
        end
    end
Loading

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...cli/src/modules/instance-ai/instance-ai.service.ts 0.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant Bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Instance AI Workflow Eval Results

8/8 built | 11/27 passed (40%)

Workflow Build Passed
Create a workflow that handles contact form submissions via a webhook. 4/5
Get all the Linear issues created in the last 2 weeks. Filter them for 1/5
Every day, get the posts made in the past day on 3 different Slack cha 3/5
Create a form that collects: name, email, company, and interest level 2/2
Every day, fetch all open GitHub issues from repository 'acme-corp/bac 0/2
Create a workflow that receives webhook notifications with a JSON body 0/3
Fetch the latest posts from the JSONPlaceholder API (GET https://jsonp 1/3
Every hour, check the current weather for London, New York, and Tokyo 0/2
Failure details

partial-action-failure [builder_issue]

The Telegram Notification node failed with 'Bad request - please check your parameters' (triggered by the mock returning {ok: false, error_code: 400, description: 'Bad Request: chat not found'}). This

happy-path [builder_issue]

The workflow fails to complete. Several critical issues prevent the checklist criteria from being met:

  1. Framework issue (empty trigger): The pre-analysis flags a FRAMEWORK ISSUE — Phase 1 retur

multi-team-creator [builder_issue]

The workflow failed to produce any cross-team report. The Filter Cross-Team Issues node produced no output because its code contains a critical builder issue: it only maps each creator to a single 'ho

unknown-creator [builder_issue]

The Filter Cross-Team Issues node produced no output at all — not even Alice's issues. The node's code correctly skips Dave (unknown creator, not in displayNameToEmail), but Alice's issues are also dr

api-error [builder_issue]

The workflow crashed with an unhandled error when the Linear API returned a 401 authentication error. The error 'Authentication required. Please provide a valid Linear API key.' propagated as a workfl

channel-not-found [builder_issue]

The workflow crashed when 'Get #product Messages' received a channel_not_found error. There is no error handling (e.g., a 'Continue on Error' setting, a try/catch branch, or an IF node to check for er

insufficient-permissions [builder_issue]

The workflow crashed when 'Get #product Messages' returned a Slack 'not_in_channel' error. The workflow error propagated and halted execution entirely — 'Aggregate #general', 'Aggregate #engineering',

happy-path [builder_issue]

The workflow failed to execute. The 'Split Issues' node has a builder issue: the 'fieldToSplitOut' parameter is empty (required field 'Fields To Split Out' is not configured). This caused the executio

no-bugs [builder_issue]

The workflow failed to execute cleanly. The 'Split Issues' node has a builder misconfiguration — the required 'Fields To Split Out' parameter is empty. This caused the execution to fail with the error

high-priority [builder_issue]

The Route by Level switch node correctly matched the 'high' level condition and produced output on its first output branch. However, the connections JSON shows that 'Route by Level' has an empty 'main

medium-priority [builder_issue]

The Switch node (Route by Level) correctly matched 'medium' and produced output on its medium branch. However, the connections JSON shows 'Route by Level': { 'main': [] } — meaning no downstream nod

low-priority [builder_issue]

The Switch node 'Route by Level' correctly matched the 'low' level condition, but the connections JSON shows that 'Route by Level' has no outgoing connections ("main": []). The 'Send Gmail' node exi

happy-path []

The workflow executed without errors and the Slack message was posted to #api-digest. However, the Filter Out qui Titles node incorrectly passed through item id=1 ('qui est esse') — visible in its out

all-filtered [builder_issue]

The scenario requires that when all posts contain 'qui' in their titles, the filter removes all items and the workflow does NOT crash or send an empty message to Slack. However, the Filter Out qui Tit

happy-path [builder_issue]

The workflow failed with a 'Could not get parameter' error on the Log to Airtable node. Multiple issues are present:

  1. The Merge Weather node used 'combineByPosition' mode with 3 inputs, but this me

no-alerts [builder_issue]

The workflow failed with 'Could not get parameter' error on the Log to Airtable node. Additionally, the Merge Weather node (configured as combineByPosition with 3 inputs) only output a single item (To

@Cadiac Cadiac requested a review from aalises April 20, 2026 15:56
@github-actions
Copy link
Copy Markdown
Contributor

Performance Comparison

Comparing currentlatest master14-day baseline

Idle baseline with Instance AI module loaded

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
instance-ai-rss-baseline 343.31 MB 386.52 MB 364.63 MB (σ 22.57) -11.2% -5.8%
instance-ai-heap-used-baseline 186.61 MB 186.88 MB 186.42 MB (σ 0.27) -0.1% +0.1%

Memory consumption baseline with starter plan resources

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
memory-heap-used-baseline 114.23 MB 114.39 MB 114.37 MB (σ 0.40) -0.1% -0.1%
memory-rss-baseline 353.43 MB 288.44 MB 290.51 MB (σ 41.09) +22.5% +21.7% ⚠️

docker-stats

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
docker-image-size-n8n 1269.76 MB 1300.48 MB 1273.86 MB (σ 10.81) -2.4% -0.3%
docker-image-size-runners 386.00 MB 412.00 MB 392.93 MB (σ 11.30) -6.3% -1.8%
How to read this table
  • Current: This PR's value (or latest master if PR perf tests haven't run)
  • Latest Master: Most recent nightly master measurement
  • Baseline: Rolling 14-day average from master
  • vs Master: PR impact (current vs latest master)
  • vs Baseline: Drift from baseline (current vs rolling avg)
  • Status: ✅ within 1σ | ⚠️ 1-2σ | 🔴 >2σ regression

@Cadiac Cadiac added this pull request to the merge queue Apr 21, 2026
Merged via the queue into master with commit 2d624a5 Apr 21, 2026
103 of 105 checks passed
@Cadiac Cadiac deleted the instance-ai-title-generation-once-enough-context branch April 21, 2026 10:48
@n8n-assistant
Copy link
Copy Markdown
Contributor

n8n-assistant Bot commented Apr 21, 2026

@n8n-assistant n8n-assistant Bot mentioned this pull request Apr 28, 2026
@n8n-assistant
Copy link
Copy Markdown
Contributor

n8n-assistant Bot commented Apr 28, 2026

Got released with n8n@2.19.0

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

Labels

Backport to Beta core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants