Skip to content

AI Context node

Selects the context items relevant to a task when the workflow runs. Selection is done by AI Context's own selector, so the node follows the same rules as automatic injection into an agent's system prompt.

Set it up

  1. Drag AI Context from the AI Context category onto the canvas.
  2. Connect a text output (the user message, a ticket body, a content summary) to the Task input. Task is required.
  3. Either pick an agent in Inherit Agent Context Config, or choose Scope Subscriptions by hand. See Agent or manual scopes.
  4. Optionally set Selection Mode and Max Tokens.
  5. Optionally connect a target entity, and always/never-include lists.
  6. Connect rendered_text to additional_context on the AI Agent Executor.

Inputs

Inputs marked config panel are set when you build the workflow. Inputs marked connection come from an upstream node.

Input Set by Description
Task connection The text to select context for. Required.
Inherit Agent Context Config config panel An agent whose saved context configuration to use.
Scope Subscriptions config panel Scope values a candidate item must match. Empty considers all published items.
Target Entity Type connection Entity type for target-entity matching, for example node.
Target Entity ID connection Numeric entity ID. Used only together with the entity type.
Always Include connection Context item IDs to include whatever the scopes say. They must still be published.
Never Include connection Context item IDs to exclude.
Selection Mode config panel minimal, relevant, broad, or empty for auto.
Max Tokens config panel Token budget for rendered_text. 0 uses the AI Context default.

Which inputs show in the config panel and which accept a connection is set on the node type, so a site builder can change it. See Configuration.

Agent or manual scopes

Candidates come from one of two places, never both.

flowchart TD
    A{Agent selected?} -- no --> M[Use the node's Scope Subscriptions]
    A -- yes --> C{Agent has saved<br/>context configuration?}
    C -- no --> M
    C -- yes --> G[Use the agent's configuration<br/>Scope Subscriptions ignored]

When the selected agent has saved context configuration, the node passes the agent to AI Context as the consumer. AI Context merges the agent's scope subscriptions, always/never-include items, selection mode and token budget into the selection, as it does when the agent runs on its own. The node's own Scope Subscriptions are ignored, and the editor hides that field and shows a note instead.

Agents without saved configuration, including agents defined in code, add nothing. The node uses its manual Scope Subscriptions.

Values you set on the node (Selection Mode, Max Tokens, Always/Never Include, the target entity) are still passed with the agent.

Selection modes

Mode Includes
minimal Global items, items tied to the target entity, and always-include items.
relevant Everything in minimal, plus items whose situational scopes match the request.
broad Everything in relevant, plus any other published item until the token budget runs out.
empty (auto) The agent's configured mode when the agent has saved configuration, otherwise broad.

Workflows saved with the old match_all mode run as broad.

Subcontext

When a selected item has subcontext children, AI Context includes them and places each child right after its parent in rendered_text.

Outputs

Output Content
rendered_text The rendered block for all selected items.
selected_ids IDs of the selected items, as strings.
selected_items Each selected item with its metadata: id, label, purpose, scope, tags, subcontext type.
item_count Number of selected items.
tokens_used Approximate tokens in rendered_text. Hidden in the editor by default.
success TRUE unless selection threw an error. An empty selection is a success.
error_message Why it failed, otherwise empty.

Use item_count or selected_items to branch, for example to skip the agent when nothing relevant was found.