Skip to content

fix(analyst): omit undefined optional finding fields before exact snapshots #568

Description

@drewstone

Problem

createTraceAnalyst emits non-canonical AnalystFinding objects when valid optional fields are absent.
AnalystRegistry.runExact then rejects those findings after paid analysis completes.

A minimal direct call returned these undefined paths:

{"undefinedPaths":["$.subject","$.rationale","$.evidence_refs[0].excerpt","$.recommended_action"]}

The values originate from two mappings.

  • evidenceRefsFromRawFinding always adds excerpt, including undefined.
  • toAnalystFinding always passes subject, rationale, and recommended_action, including undefined.

makeFinding preserves those keys.
The exact registry later throws:

AnalystRegistry.runExact analyst "question" findings finding 0 must have a canonical JSON representation

Observed environment

  • @tangle-network/agent-eval 0.144.6
  • agent-eval-rpc[dspy] 0.144.6
  • DSPy 3.2.1

The failure occurred after three successful model calls and accepted evidence.

Expected

Valid optional omissions must remain omitted in the public finding.
Every createTraceAnalyst result must satisfy the exact registry's canonical JSON contract.

Suggested fix

Build optional properties conditionally in evidenceRefsFromRawFinding and toAnalystFinding.
Add an exact-run regression with a valid finding that omits subject, rationale, recommended action, and evidence excerpt.

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