A native Codex command hook on the agent's executor. Timeout is in seconds.
Source code in src/openai_agents/codex/hooks.py
| @dataclass(frozen=True, kw_only=True)
class Hook:
"""A native Codex command hook on the agent's executor. Timeout is in seconds."""
event: HookEvent
command: str
matcher: str | None = None
timeout: int | None = None
def __post_init__(self) -> None:
if self.event not in get_args(HookEvent):
raise ValueError(f"Unknown hook event {self.event!r}")
if not self.command.strip():
raise ValueError("Hook command is required")
if self.timeout is not None and (type(self.timeout) is not int or self.timeout <= 0):
raise ValueError("Hook timeout must be a positive integer")
|