nat.front_ends.fastapi.execution_store#
In-memory execution store for HTTP HITL and OAuth interactive workflows.
Each execution tracks a single background workflow run that may be paused while waiting for a human interaction response or an OAuth consent.
Attributes#
Classes#
State for a single outstanding human interaction within an execution. |
|
State for an outstanding OAuth flow within an execution. |
|
Full state for a single execution. |
|
Thread-safe (asyncio-safe) in-memory store for HTTP interactive executions. |
Module Contents#
- logger#
- class PendingInteraction#
State for a single outstanding human interaction within an execution.
- prompt: nat.data_models.interactive.HumanPrompt#
- future: asyncio.Future[nat.data_models.interactive.HumanResponse]#
- class PendingOAuth#
State for an outstanding OAuth flow within an execution.
- class ExecutionRecord#
Full state for a single execution.
- task: asyncio.Task | None = None#
- result: Any = None#
- pending_interaction: PendingInteraction | None = None#
- pending_oauth: PendingOAuth | None = None#
- first_outcome: asyncio.Event#
- class ExecutionStore(ttl_seconds: int = DEFAULT_EXECUTION_TTL)#
Thread-safe (asyncio-safe) in-memory store for HTTP interactive executions.
- _executions: dict[str, ExecutionRecord]#
- _lock#
- _ttl_seconds = 600#
- async create_execution() ExecutionRecord#
Create a new execution and return its record.
- async get(execution_id: str) ExecutionRecord | None#
- async set_interaction_required(
- execution_id: str,
- prompt: nat.data_models.interactive.HumanPrompt,
- interaction_id: str | None = None,
Mark the execution as waiting for human interaction.
Returns the
PendingInteractionwhose.futureshould be awaited by the background task.
- async set_running(execution_id: str) None#
Transition back to running (after interaction / OAuth completes).
- async set_completed(execution_id: str, result: Any) None#
Mark the execution as successfully completed.
- async resolve_interaction( ) None#
Resolve a pending interaction by setting the future result.
Raises
KeyErrorif the execution or interaction does not exist. RaisesValueErrorif the interaction has already been resolved.