# Calling Other Processes

## Overview

In Kognitos, one process can call and run another process. The called process is referred to as a **subprocess**. There are many advantages of using subprocesses:

* **Modularity:** Decomposing automations into smaller processes enhances structure and organization.
* **Readability:** Well-organized automations are easier to read and understand.
* **Scalability:** Automations can be scaled to handle multiple tasks.
* **Maintainability:** Isolated processes simplify debugging and updating individual components.

## Mechanisms

There are several ways to call another process in Kognitos:

1. [**Run a Subprocess**](/legacy/legacy-experience/writing-automations/calling-other-processes/run-a-subprocess.md): This method is ideal for single-run scenarios where you need to capture the result and status of a subprocess.
2. [**Invoke a Subprocess**](/legacy/legacy-experience/writing-automations/calling-other-processes/invoke-a-subprocess.md): This method is useful for scenarios where the parent process can continue executing without waiting for the subprocess's status or completion.
3. [**Start Parallel Runs**](/legacy/legacy-experience/writing-automations/calling-other-processes/start-parallel-runs.md): This method provides control over parallel execution when handling multiple subprocesses simultaneously.

### Comparison

<table data-full-width="true"><thead><tr><th width="128.859375">Aspect</th><th>Running a Subprocess</th><th>Invoking a Subprocess</th><th>Starting Parallel Runs</th></tr></thead><tbody><tr><td><strong>Syntax</strong></td><td><pre><code>run &#x3C;procedure name>
</code></pre></td><td><pre><code>invoke &#x3C;procedure name>
</code></pre></td><td><pre><code>start a run where
    the procedure is &#x3C;procedure name>
</code></pre></td></tr><tr><td><strong>Execution Style</strong></td><td>Sequential Processing</td><td>Sequential Processing</td><td>Parallel Processing</td></tr><tr><td><strong>Performance</strong></td><td>Slower overall (each subprocess runs separately)</td><td>Slower overall (each subprocess runs separately)</td><td>Faster for many items (since runs happen in parallel)</td></tr><tr><td><strong>General Usage</strong></td><td>When tasks or items are independent and you want the result / status of a run</td><td>When tasks or items are independent and you don't need the result / status or a run</td><td>When tasks or items are dependent or rely on one another</td></tr><tr><td><strong>Document Processing</strong></td><td>Use when each document is independent and can be processed in isolation</td><td>Use when each document is independent and can be processed in isolation</td><td><p><br><br>Use when documents are dependent on one another, or the final outputs need to be aggregated</p><p><br></p></td></tr><tr><td><strong>Example</strong></td><td><pre><code>run "to process the sales order"
    the attachment
</code></pre></td><td><pre><code>invoke "to process the sales order" with
    the file is the document
</code></pre></td><td><pre><code>get the attachments
process each attachment as follows
  start a run where
    the procedure is "to process the sales order"
    the attachment
wait for the runs
get the runs's results as the sales orders
</code></pre></td></tr></tbody></table>

{% embed url="<https://www.youtube.com/watch?v=1gpzjeK0W9Y>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kognitos.com/legacy/legacy-experience/writing-automations/calling-other-processes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
