Skip to content

OSSS.ai.orchestration.protocol.pending_action

OSSS.ai.orchestration.protocol.pending_action

PendingAction

Bases: TypedDict

Stored on exec_state["pending_action"].

This must stay JSON-serializable and stable over time.

PendingActionResult

Bases: TypedDict

Stored on exec_state["pending_action_result"].

TurnNormalizer (or equivalent) should write this once it consumes a pending_action + user reply.

has_awaiting_pending_action(exec_state)

Canonical predicate: a pending action exists AND is actively awaiting user input.

IMPORTANT: - TurnController intentionally keeps exec_state["pending_action"] around after clearing (awaiting=False) to prevent resurrection by state merges. - Therefore, callers MUST NOT treat mere presence of "pending_action" as "still pending".

get_pending_action_type(exec_state)

Returns the pending_action.type, but ONLY when the action is awaiting. Helps keep logs/metrics from reporting phantom pending actions.

get_pending_action_owner(exec_state)

Returns pending_action.owner, but ONLY when the action is awaiting.

set_pending_confirm_yes_no(exec_state, *, owner, pending_question=None, prompt=None, resume_route, resume_pattern, reason=None, context=None, overwrite=True)

Create/overwrite a protocol-level confirm_yes_no contract.

Best-practice behaviors: - Stores only JSON-serializable primitives/dicts. - Optionally snapshots any existing pending_action into pending_action_last. - Clears any stale pending_action_result for the same owner (since we are asking a NEW question).

Backwards compatibility: - Accepts prompt= as an alias for pending_question= (older call sites). - reason is optional; defaults to "confirm_yes_no".

consume_pending_action_result(exec_state, owner)

One-shot consume the protocol result for owner.

Returns:

Type Description
Optional[PendingActionResult]
  • PendingActionResult if present for that owner (and removes it)
Optional[PendingActionResult]
  • None if absent or for a different owner

Notes: - This does NOT interpret user text. That is TurnNormalizer’s job. - This is safe to call every turn.