# `orchestrator.runtime.task_orchestration`
<!-- generated by `orchestrator understand`; the PKG is source of truth, edits here are advisory -->

[← Episteme](../README.md) · [Architecture](../architecture.md)

**Source:** [`src/orchestrator/runtime/task_orchestration.py`](../../src/orchestrator/runtime/task_orchestration.py)

5 types · 8 functions · python

## Changing this safely

**Tested by** (1): `tests.temporal.test_activities`

**Most depended-upon here** — a change to these reaches the most code (call graph, ≤4 hops):

- [`ManagerSpecialistsConfigError`](../../src/orchestrator/runtime/task_orchestration.py#L59) — reaches **4** symbols · **no test path visible**
- [`TemplateNotFoundError`](../../src/orchestrator/runtime/task_orchestration.py#L47) — reaches **3** symbols · **no test path visible**
- [`UnknownFailureActionError`](../../src/orchestrator/runtime/task_orchestration.py#L55) — reaches **3** symbols · **no test path visible**
- [`UnknownPatternError`](../../src/orchestrator/runtime/task_orchestration.py#L51) — reaches **3** symbols · **no test path visible**
- [`partition_manager_specialists`](../../src/orchestrator/runtime/task_orchestration.py#L109) — reaches **3** symbols · **no test path visible**
- [`row_to_template`](../../src/orchestrator/runtime/task_orchestration.py#L63) — reaches **3** symbols · **no test path visible**
- [`TaskOrchestrationError`](../../src/orchestrator/runtime/task_orchestration.py#L41) — reaches **2** symbols · **no test path visible**
- [`build_graph`](../../src/orchestrator/runtime/task_orchestration.py#L128) — reaches **2** symbols · **no test path visible**

_13 of the symbols other code depends on here have no test path the graph can see — worth a second look before changing them. Absence of a path is not proof of absence of a test: calls through an attribute chain (`obj.method()`) are skipped rather than guessed at, so indirect coverage is invisible._

## Types

### `ManagerSpecialistsConfigError`

[`src/orchestrator/runtime/task_orchestration.py:59`](../../src/orchestrator/runtime/task_orchestration.py#L59)

- **Extends** (1): [`TaskOrchestrationError`](../../src/orchestrator/runtime/task_orchestration.py#L41)
- **Called by** (1): [`partition_manager_specialists`](../../src/orchestrator/runtime/task_orchestration.py#L109)
- **Fields**: `http_status_code`

### `TaskOrchestrationError`

[`src/orchestrator/runtime/task_orchestration.py:41`](../../src/orchestrator/runtime/task_orchestration.py#L41)

- **Extends** (1): `Exception`
- **Implemented by** (4): [`ManagerSpecialistsConfigError`](../../src/orchestrator/runtime/task_orchestration.py#L59), [`TemplateNotFoundError`](../../src/orchestrator/runtime/task_orchestration.py#L47), [`UnknownFailureActionError`](../../src/orchestrator/runtime/task_orchestration.py#L55), [`UnknownPatternError`](../../src/orchestrator/runtime/task_orchestration.py#L51)
- **Called by** (2): [`plan_initial_ir`](../../src/orchestrator/temporal/activities.py#L72), [`replan_ir`](../../src/orchestrator/temporal/activities.py#L203)
- **Fields**: `http_status_code`

### `TemplateNotFoundError`

[`src/orchestrator/runtime/task_orchestration.py:47`](../../src/orchestrator/runtime/task_orchestration.py#L47)

- **Extends** (1): [`TaskOrchestrationError`](../../src/orchestrator/runtime/task_orchestration.py#L41)
- **Called by** (1): [`resolve_templates`](../../src/orchestrator/runtime/task_orchestration.py#L78)
- **Fields**: `http_status_code`

### `UnknownFailureActionError`

[`src/orchestrator/runtime/task_orchestration.py:55`](../../src/orchestrator/runtime/task_orchestration.py#L55)

- **Extends** (1): [`TaskOrchestrationError`](../../src/orchestrator/runtime/task_orchestration.py#L41)
- **Called by** (1): [`parse_failure_policy`](../../src/orchestrator/runtime/task_orchestration.py#L98)
- **Fields**: `http_status_code`

### `UnknownPatternError`

[`src/orchestrator/runtime/task_orchestration.py:51`](../../src/orchestrator/runtime/task_orchestration.py#L51)

- **Extends** (1): [`TaskOrchestrationError`](../../src/orchestrator/runtime/task_orchestration.py#L41)
- **Called by** (1): [`build_graph`](../../src/orchestrator/runtime/task_orchestration.py#L128)
- **Fields**: `http_status_code`

## Functions

### `build_graph`

[`src/orchestrator/runtime/task_orchestration.py:128`](../../src/orchestrator/runtime/task_orchestration.py#L128)

- **Called by** (2): [`execute_graph_pass`](../../src/orchestrator/temporal/activities.py#L141), [`submit_task`](../../src/orchestrator/registry/api/tasks.py#L113)
- **Calls** (8): [`UnknownPatternError`](../../src/orchestrator/runtime/task_orchestration.py#L51), `orchestrator.runtime.ManagerSpec`, `orchestrator.runtime.SequentialStep`, `orchestrator.runtime.SpecialistSpec`, `orchestrator.runtime.build_manager_specialists_graph`, `orchestrator.runtime.build_sequential_graph`, `orchestrator.runtime.build_single_agent_graph`, [`partition_manager_specialists`](../../src/orchestrator/runtime/task_orchestration.py#L109)

### `find_replan_request`

[`src/orchestrator/runtime/task_orchestration.py:202`](../../src/orchestrator/runtime/task_orchestration.py#L202)

- **Called by** (2): [`execute_graph_pass`](../../src/orchestrator/temporal/activities.py#L141), [`submit_task`](../../src/orchestrator/registry/api/tasks.py#L113)

### `parse_failure_policy`

[`src/orchestrator/runtime/task_orchestration.py:98`](../../src/orchestrator/runtime/task_orchestration.py#L98)

- **Called by** (2): [`execute_graph_pass`](../../src/orchestrator/temporal/activities.py#L141), [`submit_task`](../../src/orchestrator/registry/api/tasks.py#L113)
- **Calls** (3): [`FailureAction`](../../src/orchestrator/runtime/post_conditions.py#L38), [`UnknownFailureActionError`](../../src/orchestrator/runtime/task_orchestration.py#L55), `orchestrator.runtime.FailurePolicy`

### `partition_manager_specialists`

[`src/orchestrator/runtime/task_orchestration.py:109`](../../src/orchestrator/runtime/task_orchestration.py#L109)

- **Called by** (1): [`build_graph`](../../src/orchestrator/runtime/task_orchestration.py#L128)
- **Calls** (1): [`ManagerSpecialistsConfigError`](../../src/orchestrator/runtime/task_orchestration.py#L59)

### `resolve_templates`

[`src/orchestrator/runtime/task_orchestration.py:78`](../../src/orchestrator/runtime/task_orchestration.py#L78)

- **Called by** (2): [`execute_graph_pass`](../../src/orchestrator/temporal/activities.py#L141), [`submit_task`](../../src/orchestrator/registry/api/tasks.py#L113)
- **Calls** (2): [`TemplateNotFoundError`](../../src/orchestrator/runtime/task_orchestration.py#L47), [`row_to_template`](../../src/orchestrator/runtime/task_orchestration.py#L63)

### `row_to_template`

[`src/orchestrator/runtime/task_orchestration.py:63`](../../src/orchestrator/runtime/task_orchestration.py#L63)

- **Called by** (1): [`resolve_templates`](../../src/orchestrator/runtime/task_orchestration.py#L78)
- **Calls** (1): `model_validate`

### `runtime_to_ir_node_id`

[`src/orchestrator/runtime/task_orchestration.py:184`](../../src/orchestrator/runtime/task_orchestration.py#L184)

- **Called by** (2): [`replan_ir`](../../src/orchestrator/temporal/activities.py#L203), [`submit_task`](../../src/orchestrator/registry/api/tasks.py#L113)

### `terminal_node_summary`

[`src/orchestrator/runtime/task_orchestration.py:215`](../../src/orchestrator/runtime/task_orchestration.py#L215)

- **Called by** (1): [`submit_task`](../../src/orchestrator/registry/api/tasks.py#L113)

## Imports

`__future__.annotations`, [`orchestrator.core.llm`](../../src/orchestrator/core/llm/__init__.py#L1), [`orchestrator.ir.graph`](../../src/orchestrator/ir/graph.py#L1), [`orchestrator.registry._common`](../../src/orchestrator/registry/_common.py#L1), [`orchestrator.registry.agent_template`](../../src/orchestrator/registry/agent_template.py#L1), [`orchestrator.registry.db.models`](../../src/orchestrator/registry/db/models.py#L1), [`orchestrator.registry.repositories`](../../src/orchestrator/registry/repositories.py#L1), [`orchestrator.runtime`](../../src/orchestrator/runtime/__init__.py#L1), [`orchestrator.runtime.artifacts`](../../src/orchestrator/runtime/artifacts.py#L1), [`orchestrator.runtime.post_conditions`](../../src/orchestrator/runtime/post_conditions.py#L1), `typing.Any`

## Imported by

[`orchestrator.registry.api.tasks`](../../src/orchestrator/registry/api/tasks.py#L1), [`orchestrator.temporal.activities`](../../src/orchestrator/temporal/activities.py#L1), [`tests.temporal.test_activities`](../../tests/temporal/test_activities.py#L1)
