taolib.symphony.observability.snapshot#

运行时快照生成。

生成系统状态的完整快照,用于 HTTP API 和调试。 快照包含运行中的 worker、重试队列、令牌汇总和配置参数。

Classes#

SystemSnapshot

系统运行时快照。

RunningEntry

运行中 worker 的摘要信息。

RetryEntry

重试队列条目。

SnapshotGenerator

从 OrchestratorState 生成快照。

Module Contents#

class taolib.symphony.observability.snapshot.SystemSnapshot#

系统运行时快照。

running#

运行中的 worker 信息列表。

retrying#

重试队列条目列表。

completed_count#

已完成的问题数。

codex_totals#

令牌用量与运行时间汇总。

rate_limits#

当前速率限制状态(可能为 None)。

poll_interval_ms#

当前轮询间隔(毫秒)。

max_concurrent_agents#

最大并发代理数。

poll_check_in_progress#

是否正在执行轮询检查。

next_poll_due_at_ms#

下次轮询到期时间(单调时钟毫秒)。

generated_at#

快照生成时间(ISO 8601)。

running: list[dict[str, Any]]#
retrying: list[dict[str, Any]]#
completed_count: int#
codex_totals: dict[str, Any]#
rate_limits: dict[str, Any] | None#
poll_interval_ms: int#
max_concurrent_agents: int#
poll_check_in_progress: bool = False#
next_poll_due_at_ms: float | None = None#
generated_at: str#
to_dict() dict[str, Any]#

转换为字典(用于 JSON 序列化)。

class taolib.symphony.observability.snapshot.RunningEntry#

运行中 worker 的摘要信息。

issue_id: str#
identifier: str#
turn_count: int = 0#
codex_total_tokens: int = 0#
last_codex_event: str | None = None#
started_at: str = ''#
session_id: str | None = None#
codex_input_tokens: int = 0#
codex_output_tokens: int = 0#
worker_host: str | None = None#
workspace_path: str | None = None#
to_dict() dict[str, Any]#

转换为字典。

class taolib.symphony.observability.snapshot.RetryEntry#

重试队列条目。

issue_id: str#
identifier: str#
attempt: int#
delay_type: str = 'failure'#
error: str | None = None#
worker_host: str | None = None#
workspace_path: str | None = None#
to_dict() dict[str, Any]#

转换为字典。

class taolib.symphony.observability.snapshot.SnapshotGenerator#

从 OrchestratorState 生成快照。

SnapshotGenerator 接收编排器的运行时状态,将其投影为 可 JSON 序列化的 SystemSnapshot 对象,供 HTTP API 和仪表板使用。

generate(state: Any) SystemSnapshot#

从编排器状态生成系统快照。

参数:

state -- 编排器运行时状态对象,需要包含以下属性: - running: dict[str, RunningEntry] — 运行中的 worker 映射 - retry_attempts: dict[str, RetryEntry] — 重试队列映射 - completed: set[str] — 已完成的问题 ID 集合 - codex_totals: TokenUsage — 令牌用量汇总 - codex_rate_limits: dict | None — 速率限制 - poll_interval_ms: int — 轮询间隔 - max_concurrent_agents: int — 最大并发数

返回:

SystemSnapshot 实例。

static _format_datetime(value: Any) str | None#

将日期时间值格式化为 ISO 8601 字符串。

static _extract_codex_totals(state: Any) dict[str, Any]#

从编排器状态提取令牌汇总。