MultiTurnTask Class
A decorated multi-turn resilient task chain.
Distinct public class:class:Task — NOT a subclass.
The type checker enforces "no .delete() on one-shot" and
"multi-turn get_active_run takes both task_id AND input_id"
statically.
Returned by the multi_turn_task decorator.
This class wraps an internal Task (same execution model) but
exposes a strictly-typed multi-turn surface. The wrapped Task carries
ephemeral=False so the framework knows the chain semantics.
Constructor
MultiTurnTask(fn: Callable[[...], Any], opts: TaskOptions, input_type: type | None = None, output_type: type | None = None)
Parameters
| Name | Description |
|---|---|
|
fn
Required
|
|
|
opts
Required
|
|
|
input_type
|
Default value: None
|
|
output_type
|
Default value: None
|
Methods
| delete |
Force-delete the chain record + any queued inputs. , removes the chain record and all queued
steerers; resolves active + queued callers' param task_id: The chain task_id to delete. type task_id: str |
| get_active_run |
Multi-turn variant of The current turn's input_id is the match key; mismatch returns
|
| run |
Run one turn on the chain identified by |
| start |
Start one turn on the chain identified by |
delete
Force-delete the chain record + any queued inputs.
, removes the chain record and all queued
steerers; resolves active + queued callers' .result() futures
with TaskCancelled. Idempotent (no-op when the chain is
already gone).
param task_id: The chain task_id to delete.
type task_id: str
async delete(task_id: str) -> None
Parameters
| Name | Description |
|---|---|
|
task_id
Required
|
|
get_active_run
Multi-turn variant of get_active_run — REQUIRES input_id.
The current turn's input_id is the match key; mismatch returns
None.
async get_active_run(task_id: str, input_id: str) -> TaskRun[Output] | None
Parameters
| Name | Description |
|---|---|
|
task_id
Required
|
The chain task_id. |
|
input_id
Required
|
The exact input_id of the currently in-flight turn. |
Returns
| Type | Description |
|---|---|
|
The TaskRun handle bound to the currently in-flight turn
iff |
run
Run one turn on the chain identified by task_id.
async run(*, task_id: str, input: Any, input_id: str | None = None, if_last_input_id: str | None = None) -> Output
Keyword-Only Parameters
| Name | Description |
|---|---|
|
task_id
|
The chain identifier (mandatory). |
|
input
|
The turn's input value. |
|
input_id
|
Optional per-turn identifier; auto-generated when omitted. Default value: None
|
|
if_last_input_id
|
Optional Default value: None
|
Returns
| Type | Description |
|---|---|
|
<xref:Output>
|
The handler's return value for this turn. |
start
Start one turn on the chain identified by task_id and
return a TaskRun handle for that turn.
async start(*, task_id: str, input: Any, input_id: str | None = None, if_last_input_id: str | None = None) -> TaskRun[Output]
Keyword-Only Parameters
| Name | Description |
|---|---|
|
task_id
|
The chain identifier (mandatory). |
|
input
|
The turn's input value. |
|
input_id
|
Optional per-turn identifier. Default value: None
|
|
if_last_input_id
|
Optional Default value: None
|
Returns
| Type | Description |
|---|---|
|
TaskRun[<xref:Output>]
|
A TaskRun handle bound to the turn. |
Attributes
name
The registered task name (proxy of the wrapped Task).
Returns
| Type | Description |
|---|---|
|
The registered task name. |