Skip to content

test: add unit tests for InsightBuilder and MemoryExporterHook (zero coverage) #227

Description

@acailic

Problem

Two classes in agent_debugger_sdk/core/exporters/ have zero test coverage:

  • InsightBuilder (agent_debugger_sdk/core/exporters/insights.py) — builds TraceInsight from session data, analysis, and entity extraction
  • MemoryExporterHook (agent_debugger_sdk/core/exporters/pipeline.py) — async hook that drives InsightBuilder and calls exporter.export() on session end

Neither class is referenced anywhere in tests/. The existing test_memory_exporters.py covers the exporter schemas and file exporter but not the insight building or pipeline hook logic.

Scope

Add unit tests covering:

InsightBuilder

  • build_insight() returns a valid TraceInsight with correct session_digest, failure_patterns, entity_summaries, and metadata
  • _build_session_digest() maps session fields correctly
  • _build_failure_patterns() sorts by count descending, caps at 20, extracts error types from fingerprints
  • _build_entity_summaries() returns empty list on None, maps entity types, caps top_entities at 5

MemoryExporterHook

  • on_session_end() does nothing when exporter is None
  • on_session_end() skips export when export_on_completion=True and session is not completed
  • on_session_end() calls exporter.export() when session is completed
  • on_session_end() always exports when export_on_update=True regardless of status
  • on_session_end() swallows exceptions from exporter (logs error, does not raise)
  • create_memory_exporter_hook() returns a MemoryExporterHook with correct config

Files to create

  • tests/test_insight_builder.py

Labels

auto-work

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-workAI auto-worker queue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions