> ## Documentation Index
> Fetch the complete documentation index at: https://aivision.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Read the relevant procedure and prerequisites before suggesting commands. Cite the section and give an observable check. Treat sample data as illustrative. Report product actions and results only when verified in the user's environment.

# Diagnosis architecture

> How Tasks read traces, execute diagnosers and persist records and statistics.

Diagnosis applies configured checks to evidence already collected. Task completion, saved details and quality scores have distinct conditions; an empty BadCase list cannot establish that an execution was correct.

For a first hands-on run, start with [a quick check](https://aivision.mintlify.site/en/guides/diagnosis.md). The objects used here are distinct: a Diagnoser defines a check, a Dataset configures data selection, a Job configures repeatable work, a Task is one execution, and a DiagnosisRecord is an individual result. Creating a Job and completing an execution are separate events.

## From Task to results

[![Diagnosis reads and result writes](https://mintcdn.com/aivision/IXZvq4am8qG0NjqT/assets/architecture/diagnosis.en.light.svg?fit=max\&auto=format\&n=IXZvq4am8qG0NjqT\&q=85\&s=a579448edd3c988125a31d8df8ea01eb)](https://aivision.mintlify.site/assets/architecture/diagnosis.en.light.svg)

[![Diagnosis reads and result writes](https://mintcdn.com/aivision/IXZvq4am8qG0NjqT/assets/architecture/diagnosis.en.dark.svg?fit=max\&auto=format\&n=IXZvq4am8qG0NjqT\&q=85\&s=a59c90207a21beeefb8586bb676593a3)](https://aivision.mintlify.site/assets/architecture/diagnosis.en.dark.svg)

Diagnosis reads and result writes

Select the diagram to open the full-size SVG in a new tab.

Master and Worker are runtime roles of AgentLens instances. An OceanBase lease elects the Master, which schedules, dispatches and rescues tasks. A Worker's Runner executes each Task. The export box is a responsibility inside Runner, not a separate deployed service.

## Execution steps

1. Restore the Task execution snapshot and resolve its Job, Dataset, diagnosers and query window.
2. Read candidate traces and lightweight fields from SigNoz telemetry tables. An optional Selector chooses the shared sample set.
3. Run `pre_evaluate` to decide final, skip or further evaluation. Hydrate complete traces only when required.
4. Build one shared runtime projection for the trace. Rules that require only raw spans can continue to use that raw data.
5. Execute Rule or LLM checks, accumulate statistics, then construct DiagnosisRecords according to the save policy.
6. Commit terminal state with worker and attempt checks. Export terminal TaskStats only after terminal compare-and-set (CAS) succeeds.

Rule checks execute locally. LLM checks call the configured model connection. Each diagnoser defines required fields and whether missing semantics cause a skip or failure. Results are investigation clues to verify against the trace.

## Reads and writes use different channels

| Operation | Channel and location |
| - | - |
| Read traces, diagnosis records and TaskStats | AgentLens queries SigNoz OceanBase telemetry tables using SQL. |
| Persist task configuration, scheduling state and terminal statistics | AgentLens control database. |
| Export DiagnosisRecords and terminal TaskStats | AgentLens → Antcollector → SigNoz → telemetry store. |
| View diagnosis lists, details and quality results | Web → authorized Django proxy → AgentLens API. |

When platform-issued ingestion is configured, AgentLens requests a short-lived token from Django for the persisted Job's Space and Agent, then exports directly to the gateway. Django issues credentials without receiving or forwarding the diagnosis body on this path.

## Why success may yield no details or score

* Details default to BAD only. Setting `save_badcase_only` to false also saves GOOD and FAILED results produced by full evaluation.
* Final `pre_evaluate` results enter statistics only. Legal skips produce neither Metrics nor DiagnosisRecords.
* Statistics accumulate before detail filtering. BadCase counts cannot reconstruct the full sample count.
* Running statistics remain in Runner memory; the Task list is not a continuous progress feed.
* v3 quality summaries require valid coverage. Skips, failures, missing coverage or incomplete source reads can leave a summary empty. Signal-only checks or no samples also produce no quality score.

See [Diagnosis tasks](https://aivision.mintlify.site/en/guides/diagnosis-tasks.md) for parameters and [Quality analysis](https://aivision.mintlify.site/en/guides/quality.md) for metrics and review. This pipeline requires a SigNoz dataset; Langfuse observation support does not imply diagnosis support.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.