> Source: https://wexa.ai/docs/tools/get-execution

# get-execution

Poll a process flow execution. Returns `conclusion` (a human-readable Markdown summary — always prose, never parse it as JSON) and `last_agent_output` (the terminal agent's raw structured output -- whatever that step actually produced, under input_data/output_data). If that data is itself shaped like a Process Flow Manifest (flow/agents/wiring), it can be passed directly to create-process-flow's manifest argument to build a new process flow from it.

A run parked on an external agent node answers status "interop_pending" and carries `waiting_on_external_agent` — which node, which peer agent connection, and, when the external agent stopped to ask something, the `question` it asked and the shape it wants the answer in. That is how a run that is waiting is told apart from one that is merely slow, and from one that failed. In every other status the field is `null`. The question is answered in the console, on purpose: no surface answers it, because the answer is reviewed there first.

## What it is called on each surface

The wire name is `get-execution` everywhere: it is what the Wexa MCP server advertises, the REST path is
`POST /v1/get-execution`, and each SDK exposes it under its own language's naming convention.

| Surface | Name |
| --- | --- |
| Wexa MCP server | `get-execution` |
| REST API | `POST /v1/get-execution` |
| TypeScript SDK | `fabric.getExecution()` |
| Python SDK | `fabric.get_execution()` |

## Arguments

1 of the 1 argument is required. Omitting a required one is refused before the tool runs, at the validation stage, so it costs nothing and changes nothing.

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `execution_id` | string | Required | Execution id returned by run-process-flow. |

`project_id`, `projectID`, `organization_id` and `executed_by` are not arguments you pass: the
platform binds all four from the credential you authenticated with, and both SDKs refuse them
before the request leaves your process — see
[server-bound arguments](/docs/get-started/scope-and-server-bound-arguments).

## What it returns

The three surfaces wrap this differently, and code written against one will not read another
correctly — see [return shape](/docs/tools/overview#return-shape).

A real response, captured from a live call to `get-execution`:

**Result of get-execution**

**REST API**

```json
{
  "lifecycle_id": "qlc_000186",
  "result": {
    "agentflow_id": "6ab1945e7566f41b5c28e308",
    "conclusion": null,
    "execution_id": "d8b83fa9-afa7-4619-886f-55fafe5c9bc6",
    "files": [],
    "goal": "Reply OK.",
    "input_variables": null,
    "last_agent_output": null,
    "projectID": "6aa9beb7ec8121a43b6c791b",
    "start_from_agent_id": null,
    "status": "running",
    "task_id": "6ab196817566f41b5c28e31d"
  }
}
```

**Wexa MCP server**

```json
{
  "content": [
    {
      "type": "text",
      "text": "{\"lifecycle_id\":\"qlc_000186\",\"result\":{\"agentflow_id\":\"6ab1945e7566f41b5c28e308\",\"conclusion\":null,\"execution_id\":\"d8b83fa9-afa7-4619-886f-55fafe5c9bc6\",\"files\":[],\"goal\":\"Reply OK.\",\"input_variables\":null,\"last_agent_output\":null,\"projectID\":\"6aa9beb7ec8121a43b6c791b\",\"start_from_agent_id\":null,\"status\":\"running\",\"task_id\":\"6ab196817566f41b5c28e31d\"}}"
    }
  ],
  "isError": false
}
```

**TypeScript SDK**

```ts
// the object you get back IS the result — there is no `.result` to read
{
  agentflow_id: '6ab1945e7566f41b5c28e308',
  conclusion: null,
  execution_id: 'd8b83fa9-afa7-4619-886f-55fafe5c9bc6',
  files: [],
  goal: 'Reply OK.',
  input_variables: null,
  last_agent_output: null,
  projectID: '6aa9beb7ec8121a43b6c791b',
  start_from_agent_id: null,
  status: 'running',
  task_id: '6ab196817566f41b5c28e31d'
}

// The TS SDK names these camelCase — lifecycleId, traceId — where Python uses
// lifecycle_id and trace_id. Both are non-enumerable: readable, but omitted by
// Object.keys() and JSON.stringify(). `result.lifecycleId` here is undefined.
result.lifecycleId // 'qlc_000186'
```

**Python SDK**

```python
# a dict subclass; `result` is already unwrapped
{
 "agentflow_id": "6ab1945e7566f41b5c28e308",
 "conclusion": None,
 "execution_id": "d8b83fa9-afa7-4619-886f-55fafe5c9bc6",
 "files": [],
 "goal": "Reply OK.",
 "input_variables": None,
 "last_agent_output": None,
 "projectID": "6aa9beb7ec8121a43b6c791b",
 "start_from_agent_id": None,
 "status": "running",
 "task_id": "6ab196817566f41b5c28e31d"
}

out.lifecycle_id  # 'qlc_000186' — an attribute, not a key
```

Keeping the `lifecycle_id` is what lets you ask later why a call was allowed, refused or held.

### A run waiting on an external agent

An [external agent node](/docs/tools/update-process-flow) hands its whole task to an agent
on another platform. That agent can take hours, and it can stop to ask a question of its own. A run
in that state answers `status: "interop_pending"` and carries `waiting_on_external_agent`, so you
can tell a run that is waiting from one that is merely slow, and from one that failed.

| Field | Type | Notes |
| --- | --- | --- |
| `agent_id` | string | The external agent node the run is parked on. Empty when the external agent asked over MCP elicitation, which carries no node id. |
| `registration_id` | string | The peer agent connection the task was handed to — the same id [`list-peer-agents`](/docs/tools/list-peer-agents) returns. |
| `question` | string \| null | What the external agent asked before it will continue. `null` means it is still working and nobody has to do anything. |
| `question_schema` | object \| null | The shape the external agent wants its answer in, when it declared one. An A2A pause carries prose and no schema; an MCP elicitation carries both. |
| `question_mechanism` | string \| null | `a2a_pending` or `mcp_elicitation` — which of the two ways it asked. |

The field is `null` on every run that is not parked, including a finished run that was cancelled
while a question was open.

**A question is answered in the console and nowhere else.** No surface gains a way to answer one:
the answer is reviewed there first, helped by a context graph suggestion that is never sent for
you. Nothing here returns that suggestion, nor the tokens the platform uses to resume the run.

A real response, captured from a live run parked on an external agent:

```json
{
  "agentflow_id": "6ab36485f19beb4f0ed39e9a",
  "execution_id": "2b0cf9a7-9be7-4142-a578-8695372db913",
  "goal": "Settle the outstanding invoice for ACME-7.",
  "status": "interop_pending",
  "waiting_on_external_agent": {
    "agent_id": "",
    "question": "Which account should I settle, and who owns it?",
    "question_mechanism": "mcp_elicitation",
    "question_schema": {
      "description": "What the external agent needs before it can act.",
      "properties": {
        "account_code": {
          "description": "The customer's account code",
          "title": "Account Code",
          "type": "string"
        },
        "owner_email": {
          "description": "Who owns that account",
          "title": "Owner Email",
          "type": "string"
        }
      },
      "required": [
        "account_code",
        "owner_email"
      ],
      "title": "AccountAnswer",
      "type": "object"
    },
    "registration_id": "6ab36477825fc7bd72f3324b"
  }
}
```

## Calling it

The same call on all four surfaces. Pick a tab once and every code block in the documentation follows it.

The ids in this example are real: they resolve against the project the documentation is written
against, so the call runs as written once you point it at your own deployment. Swap them for the
ids of your own objects.

**Call get-execution**

**Wexa MCP server**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get-execution",
    "arguments": {
      "execution_id": "d8b83fa9-afa7-4619-886f-55fafe5c9bc6"
    }
  }
}
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/get-execution \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"execution_id":"d8b83fa9-afa7-4619-886f-55fafe5c9bc6"}'
```

**TypeScript SDK**

```ts
import { Fabric } from '@wexa-fabric/sdk'

const fabric = new Fabric()
const { result } = await fabric.getExecution({
  execution_id: "d8b83fa9-afa7-4619-886f-55fafe5c9bc6"
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.get_execution(execution_id="d8b83fa9-afa7-4619-886f-55fafe5c9bc6")
```

## Errors

Both SDKs raise the same typed errors, chosen from the gateway's own error string first and its
HTTP status second. `get-execution` checks the `fabric:orchestrate.read` grant, and reaches the seven classes every
tool reaches — listed under [the common set](/docs/tools/errors#the-common-set). These are the ones specific to it:

| Error | Status | Raised when |
| --- | --- | --- |
| `NotFound` | 404 | `execution_id` matches no execution in this project. |
| `ConfigurationError` | 5xx | `get-execution` is not available to you. Retrying will not help. |

## Governance

Every call to `get-execution` runs through the same ten-stage lifecycle as every other Wexa tool: the
credential is resolved to a scope, the `fabric:orchestrate.read` grant is checked, quota is drawn down, the arguments are
validated, policy rules are evaluated, the call is executed, the result is shaped and redacted, and an audit
record is written. The `lifecycle_id` in the response is the handle to that record.

`get-execution` only reads, so it is not marked consequential: it is audited lightly and is never held for
approval. It still consumes quota and is still refused by policy like anything else.

## See also

[The tool index](/docs/tools/overview), [errors](/docs/tools/errors),
and [which identifier goes where](/docs/tools/identifiers).
