observability

Unified observability events via Redis pub/sub and sorted sets.

Publishes events for tool calls, response phases, and background tasks. All events are both streamed (pub/sub) and persisted (sorted sets) so dashboards can consume them in real-time or query history.

observability.set_observability_redis(client)[source]

Set the observability redis.

Parameters:

client (aioredis.Redis | None) – The client value.

Return type:

None

observability.generate_request_id()[source]

Generate request id.

Returns:

Result string.

Return type:

str

async observability.publish_tool_event(tool_name, arguments=None, result_preview='', duration_ms=0, success=True, user_id='', channel_id='', request_id='')[source]

Publish tool event.

Parameters:
  • tool_name (str) – The tool name value.

  • arguments (dict[str, Any] | None) – The arguments value.

  • result_preview (str) – The result preview value.

  • duration_ms (float) – The duration ms value.

  • success (bool) – The success value.

  • user_id (str) – Unique identifier for the user.

  • channel_id (str) – Discord/Matrix channel identifier.

  • request_id (str) – The request id value.

Return type:

None

async observability.publish_response_event(phase, request_id='', channel_id='', user_id='', model='', duration_ms=0, tool_rounds=0, error='', **extra)[source]

Publish response event.

Parameters:
  • phase (str) – The phase value.

  • request_id (str) – The request id value.

  • channel_id (str) – Discord/Matrix channel identifier.

  • user_id (str) – Unique identifier for the user.

  • model (str) – The model value.

  • duration_ms (float) – The duration ms value.

  • tool_rounds (int) – The tool rounds value.

  • error (str) – The error value.

  • **extra (Any) – Additional keyword arguments.

Return type:

None

async observability.publish_background_event(task_name, status='running', task_id='', progress=None, result='', error='', **extra)[source]

Publish background event.

Parameters:
  • task_name (str) – The task name value.

  • status (str) – The status value.

  • task_id (str) – Background task identifier.

  • progress (float | None) – The progress value.

  • result (str) – Result data.

  • error (str) – The error value.

  • **extra (Any) – Additional keyword arguments.

Return type:

None

async observability.get_recent_events(category='tools', limit=100)[source]

Return recent events for category (tools, responses, background).

Return type:

list[dict[str, Any]]

Parameters: