Skip to content

Instrument the sampling loop to track each iteration attempt, providing visibility into retry behavior #472

Closed as not planned

Description

@psschwei

Description:
Instrument the sampling loop to track each iteration attempt, providing visibility into retry behavior.

Detailed Requirements:

  1. Add spans for sampling operations:
    • sampler.sample - Overall sampling operation
    • sampler.iterate - Single sampling iteration
    • sampler.repair - Repair attempt
    • sampler.select - Selection from candidates
  2. Add attributes:
    • strategy - Sampling strategy name
    • iteration - Current iteration number
    • max_iterations - Maximum allowed iterations
    • status - success/failure/repair
  3. Track iteration outcomes:
    • Add span events for validation pass/fail
    • Record reason for rejection

Files to Modify:

  • mellea/stdlib/sampling/base.py - Instrument BaseSamplingStrategy
  • mellea/stdlib/sampling/rejection.py - Instrument RejectionSamplingStrategy
  • mellea/stdlib/sampling/sofai.py - Instrument SoFAISamplingStrategy
  • mellea/stdlib/sampling/majority_voting.py - Instrument MajorityVotingStrategy

Span Hierarchy Example:

sampler.sample
├── sampler.iterate (attempt 1)
│   ├── backend.request
│   └── validator.check (FAIL)
├── sampler.iterate (attempt 2)
│   ├── backend.request
│   └── validator.check (PASS)
└── [success]

Acceptance Criteria:

  • Each sampling iteration has its own span
  • Iteration count and outcomes tracked
  • Strategy-specific behavior captured
  • Spans correctly nested

Activity

  1. ajbozarth commented on May 8, 2026

    @ajbozarth
    Member

    Closing as part of the tracing epic (#444) re-plan. This sub-issue predates the plugin/hooks pattern (PR #653) and the GenerationMetadata partition (PR #908); its spec has drifted.

    Replacement: part of #1050 — sampling, validator, and formatter spans via plugin hooks (rolled together since the mechanism is identical across all three).

    See #444 for the full refreshed plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions