mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 05:50:44 +08:00
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import sqlite3
|
|
|
|
|
|
def main() -> None:
|
|
db = r"D:\project\chatgpt\oclaw\data\ai_ops.sqlite"
|
|
con = sqlite3.connect(db)
|
|
cur = con.cursor()
|
|
|
|
row = cur.execute(
|
|
"select trace_id,payload,timestamp from trace_event where event_type='response_sent' order by id desc limit 1"
|
|
).fetchone()
|
|
print("latest_response_sent:", row[2] if row else None)
|
|
if not row:
|
|
con.close()
|
|
return
|
|
|
|
trace_id = str(row[0] or "")
|
|
print("trace_id:", trace_id)
|
|
|
|
evts = cur.execute(
|
|
"""
|
|
select event_type,payload,timestamp
|
|
from trace_event
|
|
where trace_id=?
|
|
and event_type in (
|
|
'gateway_received','model_chat_start','ws_first_token',
|
|
'manager_decision','router_decision','response_sent'
|
|
)
|
|
order by id asc
|
|
""",
|
|
(trace_id,),
|
|
).fetchall()
|
|
|
|
keep_keys = [
|
|
"elapsed_ms_since_gateway_start",
|
|
"elapsed_ms",
|
|
"interaction_mode",
|
|
"requested_specialist",
|
|
"manager_selected_specialist",
|
|
"dispatch_reason",
|
|
"manager_self_mode",
|
|
"instruction_chars",
|
|
"ws_client_send_ms",
|
|
"ws_first_token_ms",
|
|
"channel",
|
|
"run_id",
|
|
]
|
|
for et, pl, ts in evts:
|
|
try:
|
|
obj = json.loads(pl) if isinstance(pl, str) else pl
|
|
except Exception:
|
|
obj = pl
|
|
if isinstance(obj, dict):
|
|
pick = {k: obj.get(k) for k in keep_keys if k in obj}
|
|
print(et, ts, pick)
|
|
else:
|
|
print(et, ts, obj)
|
|
|
|
con.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|