Skip to main content

Quality Lab

Quality Lab is the product-facing validation layer for API collections. It runs repeatable cases through search, target selection, plan synthesis, and optional execution.

Use it before enabling an API collection for real Planflow usage. It should answer four questions:

  1. Can search find the right target family?
  2. Can target selection choose the correct final tool?
  3. Can plan synthesis fill or request the required inputs?
  4. Can execution reach the downstream API safely?

Validation Flow

Quality Lab should be run as a staged gate. Do not start with live execution if search or plan evidence is not stable.

StageInputOutputStop If
BuildOpenAPI/MCP/Python sourcescollection artifact, readiness reportschema coverage is too low
Searchquery casesTop-K rows and evidenceexpected target is absent
SelectTop-K + optional LLM targettarget_selector blockselector is ambiguous for critical cases
Planselected target + entitiesPlan, slots, diagnosticsrequired fields are unsatisfied
Executeplan + adapter authrunner events and assertionsauth or mutation safety fails
Learnscrubbed resultsuggestions and shadow rankpayload scrubbing fails

This keeps failures classified by stage instead of collapsing everything into a single "agent failed" result.

Case Modes

ModePurposeTypical Gate
searchCheck retrieval and Top-K behaviorexpected target is in Top-K
planCheck target selection and plan synthesisselected target and plan tools match expectations
executeRun the plan through the adapter when safeHTTP result and assertions pass

Search and plan cases should run frequently. Execute cases should run only when auth readiness and mutation safety are understood.

Case Schema

{
"id": "member-search-001",
"mode": "search",
"query": "Find member delivery detail",
"expected_target": "getMemberDeliveryDetail",
"expected_top_k": 8,
"assertions": [
{"type": "top_k_contains", "tool": "getMemberDeliveryDetail", "k": 8}
]
}

Fields are intentionally additive. Existing search-only cases should keep working when plan or execute fields are added.

Result Shape

A useful Quality Lab result should preserve each stage as a separate object.

SectionPurpose
searchTop-K results, hit position, score breakdown
target_selectorLLM target, selected target, override flag, reason codes
planplan id, steps, user input slots, synthesis diagnostics
executerunner events, HTTP status, latency, assertions
auth_readinessstructured auth preflight state
learningsuggestions created or shadow-applied
failurestable failure reason and failed stage

Example:

{
"case_id": "member-plan-001",
"mode": "plan",
"status": "passed",
"latency_ms": {
"search": 42,
"target_selection": 3,
"plan": 914
},
"search": {
"hit": true,
"hit_rank": 1,
"top_k": 8
},
"target_selector": {
"llm_target": "getMemberDeliveryList",
"selected_target": "getMemberDeliveryDetail",
"overrode_llm": true,
"reason_codes": ["llm_target_overridden", "selected_by_strong_evidence"]
},
"plan": {
"status": "synthesized",
"tools": ["getMemberDeliveryDetail"],
"user_input_slots": []
}
}

Execute Safety

Mutating execute cases should require:

  • explicit mutation allowance
  • dev host allowlist
  • cleanup steps
  • assertions
  • structured failure recording

If a case cannot meet those requirements, keep it in search or plan mode. Read-only execution is still an adapter operation and should go through auth readiness before calling the downstream API.

Auth Readiness

Execute mode should distinguish preflight failures from real API failures.

ReasonMeaning
auth_context_requiredNo usable runtime user/session context
auth_profile_missingCollection requires auth but has no auth profile
auth_header_resolution_failedAdapter could not resolve execution headers
auth_failedDownstream API returned 401 or 403

Do not store raw tokens, cookies, user ids, or generated auth header values in Quality Lab results. Store header names and structured reason codes only.

Start with small suites and expand only when the signal is stable.

SuitePurposeSuggested Cadence
search_core_30Search cases from real OpenAPI summariesevery search/semantic change
business_manual_20Representative business queries written by operatorsevery release candidate
plan_e2e_10Target selection and plan synthesis casesevery plan/selector change
execute_read_5Read-only execution cases with auth readinessdev deployment smoke
execute_mutation_3Dev-only mutation cases with cleanupmanual or gated CI only

Acceptance Metrics

Metrics should be collection-specific, but a healthy large API collection should track:

MetricWhat It Shows
search hit@Kwhether retrieval keeps the correct tool visible
search Top-1whether the first candidate is usually correct
target selector accuracywhether deterministic guardrails help rather than hide failure
plan hit ratewhether selected targets become executable plans
execute read success ratewhether adapter/auth/request execution works
structured failure ratewhether failures are classified instead of becoming 500s
latency by stagewhere runtime is spent

Public quality claims should include the dataset, model when applicable, run configuration, and stored result artifact.

Promotion Policy

Use Quality Lab results as a promotion gate for search tuning and trace learning.

Change TypeRequired Evidence
alias or semantic metadatasearch suite improves or stays stable
selector override policyplan cases show correct final target
contract extraction changereadiness and contract coverage improve
learning suggestion promotionshadow result improves and scrub check passes
execute enablementauth readiness and read-only assertions pass

Do not promote a change because one manual query looked better. Keep the failing and fixed evidence side by side.

Troubleshooting

SymptomLikely CauseWhat To Inspect
Search passes but plan failsRequired fields are unsatisfiedplan.user_input_slots, IO contracts
Plan passes but execute failsAuth or request adapter issueauth_readiness, runner events
LLM target differs from selected targetStrong selector evidence overrode or ambiguity was detectedtarget_selector.reason_codes
Execute returns 401/403Runtime auth reached the API but was rejectedauth profile and downstream API policy
Results improve in shadow onlyLearning suggestion is not promotedpromotion policy and Quality Lab approval
Execute succeeds but assertions failAPI reached but returned the wrong shaperesponse schema and assertion paths