vibe.assistant.logging

Assistant interaction logging system.

This module provides logging functionality for assistant conversations, tracking requests, responses, and errors for debugging and monitoring.

AssistantLogManager

Manages assistant interaction logs with structured logging.

__init__

__init__(log_directory: Path | None = None) -> None

Initialize the assistant log manager.

Parameters:
  • log_directory (Path | None, default: None ) –

    Directory to store log files. If None, uses unified data directory.

log_assistant_request

log_assistant_request(endpoint_name: str, assistant_name: str, turn_id: str, provider_payload: object, session_id: str | None, sequence: int, **extra: object) -> str

Log an assistant request with provider-formatted payload.

Parameters:
  • endpoint_name (str) –

    Name of the endpoint from main config.yml

  • assistant_name (str) –

    Name of the assistant

  • turn_id (str) –

    Turn ID for correlation

  • provider_payload (object) –

    Provider-specific formatted messages/payload (post-conversion)

  • session_id (str | None) –

    Session identifier

  • sequence (int) –

    Sequence number for this turn

  • **extra (object, default: {} ) –

    Additional fields to include in the log entry (e.g., previous_response_id)

Returns:
  • str

    Turn ID (same as input, for consistency)

transform_chunks

transform_chunks(chunks: list[StreamChunk]) -> str

Convert a sequence of StreamChunk items into a readable summary string.

The output includes tool calls (with progressively collected arguments) and the first contiguous text segment for quick inspection in logs.

log_assistant_response_chunk

log_assistant_response_chunk(endpoint_name: str, assistant_name: str, turn_id: str, session_id: str | None, sequence: int, raw_chunk: object, chunk_index: int | None = None) -> None

Log a raw provider response chunk.

log_sse_event

log_sse_event(turn_id: str, sse_content: str) -> None

Log an SSE event that's being sent to the client.

This logs the raw SSE events as they're sent to the browser, useful for debugging the streaming output and correlating with input chunks.

Parameters:
  • turn_id (str) –

    Turn ID for correlation with stream chunks

  • sse_content (str) –

    The raw SSE event string being sent

log_assistant_error

log_assistant_error(endpoint_id: str, assistant_name: str, turn_id: str, error: Exception, metadata: dict[str, Any] | None = None, *, session_id: str | None = None, sequence: int | None = None) -> None

Log an assistant error.

Parameters:
  • endpoint_id (str) –

    Name of the endpoint from main config.yml

  • assistant_name (str) –

    Name of the assistant

  • turn_id (str) –

    Turn ID for correlation

  • error (Exception) –

    Exception that occurred

  • metadata (dict[str, Any] | None, default: None ) –

    Additional metadata

  • session_id (str | None, default: None ) –

    Session identifier for correlation

  • sequence (int | None, default: None ) –

    Sequence number for correlation

set_log_directory

set_log_directory(log_directory: Path) -> None

Set the log directory for assistant logs.

Parameters:
  • log_directory (Path) –

    Path to the log directory

reinitialize_log_manager

reinitialize_log_manager() -> None

Reinitialize the global log manager to use the unified data directory.

This should be called after the data directory manager is initialized.