AgentPhase#
Distinguish UI streams, extension notifications, and external replies. See the guide.
- class zett_agent.events.AgentPhase(*values)[source]#
Exclusive execution phase of one request-scoped AgentState.
Complete request state machine. The enclosing ACTIVE REQUEST box gives every active phase the same failure and cancellation exits. Bidirectional arrows enter an operation to the right and return to READY on completion:
+-----------------------+ | CREATED | +-----------------------+ | | +---------------+-------------------------------------------------------------+ | | ACTIVE REQUEST | | | shared error / cancellation exits | | v | | +-----------------------+ | | | LOADING_CONTEXT | | | | on_tool() | | | | on_state() | | | | on_message() | | | +-----------------------+ | | | +---------------+ | | | | | v | | | +-----------------------+ +-----------------------+ | | | | READY |<- compact/done ->| COMPACTING | | | | | | +-----------------------+ | | | | | | | | | | +-----------------------+ | | | | |<- generate/done >| GENERATING | | | | | | +-----------------------+ | | | | | | | | | | +-----------------------+ | | | +-----------------------+<- tool/done ---->| RUNNING_TOOL | | | | | +-----------------------+ | | | | | | | | | | cancellation +---------------+-------------------------------------------------------------+ | | +- exception -----------------------+ | | | v v v +-----------------------+ +------------------------+ +---------------------------+ | COMPLETED | | FAILED | | CANCELLED | | after_run() | | on_error() | | RunCancelledEvent | | on_success() | | re-raise error | | re-raise cancellation | +-----------------------+ +------------------------+ +---------------------------+
Active phases are LOADING_CONTEXT, READY, COMPACTING, GENERATING, and RUNNING_TOOL. COMPLETED, FAILED, and CANCELLED are terminal for the current request. A later request receives a fresh AgentState beginning at CREATED.
- property accepts_new_request: bool#
Return whether an agent may start another request from this phase.