SysOps: voice-agy-webbuilder-backup — 2026-06-23 10:04 UTC
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
"""Agent event logging helpers used by the Tools API."""
|
||||
|
||||
from typing import Any, Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from app.agent_names import normalize_agent_key
|
||||
from app.db import execute_returning, json_param
|
||||
|
||||
|
||||
@@ -17,7 +19,21 @@ def log_agent_event(
|
||||
related_table: Optional[str] = None,
|
||||
related_id: Optional[int] = None,
|
||||
channel: str = "dashboard",
|
||||
correlation_id: Optional[str] = None,
|
||||
source_agent: Optional[str] = None,
|
||||
target_agent: Optional[str] = None,
|
||||
) -> dict[str, Any]:
|
||||
meta = dict(metadata or {})
|
||||
if correlation_id:
|
||||
meta.setdefault("correlation_id", correlation_id)
|
||||
if source_agent:
|
||||
meta.setdefault("source_agent", normalize_agent_key(source_agent))
|
||||
if target_agent:
|
||||
meta.setdefault("target_agent", normalize_agent_key(target_agent))
|
||||
if "correlation_id" not in meta:
|
||||
meta.setdefault("correlation_id", str(uuid4()))
|
||||
|
||||
normalized = normalize_agent_key(agent_name)
|
||||
row = execute_returning(
|
||||
"""
|
||||
INSERT INTO agent_events (
|
||||
@@ -28,12 +44,12 @@ def log_agent_event(
|
||||
RETURNING *
|
||||
""",
|
||||
(
|
||||
agent_name,
|
||||
normalized,
|
||||
agent_type,
|
||||
event_type,
|
||||
title,
|
||||
body,
|
||||
json_param(metadata),
|
||||
json_param(meta),
|
||||
status,
|
||||
related_table,
|
||||
related_id,
|
||||
|
||||
Reference in New Issue
Block a user