On this page
Sommatic Docs
Open portal

RAG Compose Prompt

Constructs a RAG (Retrieval-Augmented Generation) prompt by combining a query with retrieved context.

View as Markdown
Open in
AI Experimental ai.rag.compose Version 1.0.0 Execution: sync

Experimental stub. It returns a fixed { message, timestamp } object through out and does not build any prompt: query, context, template and max_context_tokens are ignored.

This operator formats a list of retrieved documents into a context block and injects it into a "Answer with context" prompt template.

Use Cases:

  • Q&A over internal documentation.
  • Summarizing search results.
  • Grounding LLM responses in factual data.

How it works

  1. Resolves the node config: expressions in config keys are evaluated against the run; the incoming item is used as-is.
  2. Returns { message: "Executed ai.rag.compose", timestamp } with no port, so the engine routes it to out.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-rag-compose",
  "label": "Compose RAG prompt",
  "operator_slug": "ai.rag.compose",
  "operator_version": "1.0.0",
  "config": {
    "max_context_tokens": 4000
  }
}

Configuration

template string Optional

Must contain {{context}} and {{query}} placeholders.

Default: Context: {{context}} Query: {{query}} Answer using only the context above:

max_context_tokens number Optional

Limit context size to fit model window.

Default: 4000

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

template / max_context_tokens
Declared but ignored.

Output ports

out default

Every run.

Data
{
  "message": "Executed ai.rag.compose",
  "timestamp": "2026-11-26T15:04:05.000Z"
}
error

Never emitted by the code.

In expressions

What a later node can read from this node's output with $("RAG Compose Prompt").item.json.<path> (write your node's label instead of RAG Compose Prompt). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("RAG Compose Prompt").item.json.promptstringThe worker does not return it: reads as undefinedThe final prompt ready for generation. —
$("RAG Compose Prompt").item.json.messagestringNot suggested by the editor= "Executed ai.rag.compose"—
$("RAG Compose Prompt").item.json.timestampstringNot suggested by the editor= "2026-11-26T15:04:05.000Z"—

— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Input contract

query string Required

The user question.

context array | string Required

List of text chunks or already joined string.

Output contract

prompt string Optional

The final prompt ready for generation.

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "ai.rag.compose",
  "name": "RAG Compose Prompt",
  "category": "ai",
  "version": "1.0.0",
  "description": "Constructs a RAG (Retrieval-Augmented Generation) prompt by combining a query with retrieved context.\n\n  This operator formats a list of retrieved documents into a context block and injects it into a \"Answer with context\" prompt template.\n\n  **Use Cases:**\n  - Q&A over internal documentation.\n  - Summarizing search results.\n  - Grounding LLM responses in factual data.",
  "capabilities": [
    "rag",
    "prompt-engineering",
    "context-window"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "template": {
        "type": "string",
        "title": "RAG Template",
        "format": "textarea",
        "default": "Context:\n{{context}}\n\nQuery:\n{{query}}\n\nAnswer using only the context above:",
        "description": "Must contain {{context}} and {{query}} placeholders."
      },
      "max_context_tokens": {
        "type": "number",
        "default": 4000,
        "title": "Max Context Tokens",
        "description": "Limit context size to fit model window."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "The user question."
      },
      "context": {
        "type": [
          "array",
          "string"
        ],
        "description": "List of text chunks or already joined string."
      }
    },
    "required": [
      "query",
      "context"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "prompt": {
        "type": "string",
        "description": "The final prompt ready for generation."
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Composed",
      "is_default": true
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "rag",
    "prompt",
    "compose"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
No
Retries (retryOnFail)
No
Capabilities
ragprompt-engineeringcontext-window
Tags
ragpromptcompose

Notes and limits

  • Not implemented: placeholder substitution, context joining and context-size limits. To build a RAG prompt today, use data.template or ai.generate with your own template.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs