﻿# n8n AI sub-node expressions resolve to the first input item

Diagnose repeated labels or search parameters in n8n AI workflows by checking first-item expression resolution inside sub-nodes before changing embeddings or document content.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-n8n-subnode-first-item-expressions/
Language: en

## Notice a batch-specific failure

A document-ingestion workflow works with a sample file, then assigns the same source label to every document in a batch. The extracted text may be correct while metadata is wrong. In n8n, a critical difference lies between ordinary root-node expressions and expressions in AI sub-nodes. Check where the expression is evaluated before treating repeated evidence labels as an embedding problem.

## Read the first-item rule literally

The [Default Data Loader reference](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.documentdefaultdataloader) states that sub-node expressions resolve to the first input item. A `$json` reference that varies normally across root-node items can therefore keep selecting the initial value in this context. The [Vector Store Retriever reference](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.retrievervectorstore) documents the same parameter behavior. A successful batch run does not prove every sub-node parameter was personalized to each document.

## Distinguish loading mode from expression scope

Default Data Loader offers loading all input data or constructing specific data using expressions. Its metadata accompanies documents into the vector store. Inspect both the loaded content and the associated identifiers. Do not infer that loading several documents changes how a metadata expression resolves. A correct passage with another document's label can be more misleading than an explicit retrieval failure because it appears fully attributable.

## Isolate per-item work when required

The [Loop Over Items guide](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.splitinbatches) explains configurable batches and the distinction between loop output and combined done output. A deliberately single-item batch can make a first-item expression refer to the intended current item at that stage. Evaluate the complete loop wiring and termination, rather than adding a loop around an already correct ordinary node. Most n8n nodes process item lists without manual looping; the exception being addressed is the sub-node mapping.

## Verify with distinguishable documents

Use sample documents with clearly different labels and clauses. Inspect the stored metadata, then retrieve a clause from each and compare attribution. The [citation-support guide](/journal/rag-citation-precision-completeness/) explains why source identity matters; [tool observations](/journal/learn-codex-tool-observation/) distinguish an executed workflow from a correct mapping. Retain a multi-item check, because a successful single-document test cannot expose this particular failure mode.
