> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getvirtualbrain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Passing Data Safely Between Blocks

> The routing decision where most Apps break, plus how to design hand-offs, prevent prompt bleed, and keep every block within budget

Upstream block outputs are the hand-offs that carry results through the pipeline. For every connection between two blocks you make one decision: route the upstream output Inline or as a Knowledge Source. This decision, not the prompts, is where most Apps break.

## The routing decision

Ask two questions about the upstream output:

1. Is it concise (1,000 words or fewer) AND useful as search context for the next block?
2. Or is it long, or does the next block only need extracts of it?

| Route INLINE when                                       | Route as KNOWLEDGE SOURCE when                                  |
| ------------------------------------------------------- | --------------------------------------------------------------- |
| The output is 1,000 words or fewer                      | The output is long or verbose                                   |
| The next block needs the full content                   | The next block needs only parts of it                           |
| It serves as search context for a KS or web search      | Combined upstream content exceeds \~5,000 words                 |
| Name it descriptively: `/rfp_summary`, `/bill_analysis` | Then add descriptive retrieval guidance in the consuming prompt |

<Warning>
  Before you tune a single sentence of a prompt, confirm every hand-off between blocks is routed correctly.
</Warning>

## Designing the hand-off

Make upstream outputs consumable. Three practices keep the data clean as it travels.

<Steps>
  <Step title="Fix the shape of the upstream output">
    If Block 2 consumes Block 1's output, specify Block 1's headers and table columns verbatim in Block 1's prompt, then reference those exact section names in Block 2's prompt.
  </Step>

  <Step title="Put the inputs in a clearly labeled section at the end of the prompt">
    Keep the data out of your instructions. List every inline variable in a dedicated section at the very end of the prompt, each introduced with a clear label.

    ```text theme={null}
    Bill summary: /bill_summary
    Eligibility criteria: /eligibility_criteria
    ```

    A clean separation between instructions and data is the surest way to stop the Mainframe from confusing the two, which is what causes "prompt bleed" on long inputs.
  </Step>

  <Step title="Refer to content, never to blocks">
    Write "using the extracted requirements", never "using the output of Block 2". At runtime the Mainframe sees content, not block numbers; block references are meaningless to it.
  </Step>
</Steps>

<Warning>
  **Prompt bleed** is the most common failure on long inputs: the Mainframe mixes your data into your instructions and follows the wrong one. The fix is structural. Put every inline variable in a single labeled section at the very end of the prompt, kept clearly apart from the instructions above it.
</Warning>

## When the pipeline gets heavy

When a consolidation block must absorb several upstream outputs and the total approaches \~5,000 words, reach for one of three relief valves.

| Relief valve                            | How it works                                                                                                                  |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **Switch to KS routing**                | Route the upstream outputs as Knowledge Sources and give per-source retrieval guidance in the prompt.                         |
| **Insert a Hidden summarization block** | A [Hidden block](/apps-academy/key-concepts) condenses the verbose output to 200 to 300 words, then route the summary inline. |
| **Split into parallel sub-blocks**      | Each sub-block handles fewer inputs, plus a final merge block consolidates them.                                              |

## Keeping blocks within budget

A few habits keep every block fast and faithful to its instructions:

* **Keep a single inline output short.** Roughly a page or two (about 1,000 words) is the ceiling for one inline upstream variable. Past that, route it as a Knowledge Source.
* **Watch the combined load on a block.** When several inline outputs feed the same block and together they run to more than a few pages, switch the heaviest ones to KS routing or summarize them first.
* **Stay around a dozen blocks.** If the process looks like it needs more, merge the steps the Mainframe can handle in one pass rather than adding blocks.
* **Keep inputs to 5 to 7.**
* **Let the symptom guide you.** If a block runs slowly or starts losing detail, it is carrying too much: move data into Knowledge Sources instead of injecting it inline.

## Next

<CardGroup cols={1}>
  <Card title="Prompting" icon="pen-nib" href="/apps-academy/prompting">
    The standard prompt template and the rules that matter most.
  </Card>
</CardGroup>
