← all docs · north-os20 July 2026

Eval agent-quality grounding fix — implementation plan

Status: In progress
Author: OpenAI Codex
Date: 2026-07-20
Repo: north-os
Related: design spec; NOS-183

Goal: preserve real search and document-read provenance through the legal-assistant graph without exposing coverage artifacts to the model, then re-measure the unchanged agent-quality gate.

Architecture: graph state preserves validated search/email touch artifacts and a minimal document-read artifact containing only checker-required identity and range provenance. The model receives a sanitized projection with no artifact field.

Tech stack: Bun, TypeScript, LangChain ToolMessage, LangGraph, Vitest.

Output structure

Implementation tasks

Tasks 0–5 record shipped Defect 1. Tasks 6–8 extend the same state/model-view split to document reads without changing the checker.

Task 0 — preflight status and baseline

EVAL_AGENT=1 bunx dotenv \
  -e /home/kwiss/workspace/north-os/.env.local \
  -e /home/kwiss/workspace/north-os/.env -- \
  bun --filter=@workspace/agent-runtime run eval:agent-quality

Observed baseline: 0/8 (0.0%) on 2026-07-20; every case failed. Non-fatal product_event insert errors were logged and did not abort the run.

Task 1 — establish the red regression

Test: packages/agent-runtime/src/agents/legal-assistant/graph.test.ts

Task 2 — preserve state, sanitize model input

Modify: packages/agent-runtime/src/agents/legal-assistant/graph.ts

Task 3 — package verification and post-fix measurement

Task 4 — Defect 2 disposition

Scoped follow-up if deferred: trace the HFA source across title search, RRF, best-extent recovery, and Voyage rerank; add a deterministic named-instrument ordering fixture; then introduce title/entity-aware scoring only at the stage proven responsible. Acceptance: a named instrument's own source ranks ahead of same-topic clauses in other instruments without query-specific literals or checker changes.

Task 5 — outcome record, adversarial review, and delivery

Task 6 — establish the document-read red regression

Test: packages/agent-runtime/src/agents/legal-assistant/graph.test.ts

Task 7 — retain the minimal document-read state artifact

Modify: packages/agent-runtime/src/agents/legal-assistant/graph.ts

Task 8 — verify, measure, diagnose, and deliver the follow-up

Verification matrix

Outcome — 2026-07-20

Outcome — 2026-07-20 document-read projection follow-up

CaseDefect 1 baselinePost-changeConfirmDiagnosis
grounded-lol-bond-mortgagePASSFAILFAILDifferent path, not document provenance. The first run rejected tool narration; the confirm found no admissible search evidence. This previously passing search-only case exposes answer/retrieval variance and remains Defect 2 territory.
grounded-promissory-noteFAILFAILFAILThe read artifact is now source-bearing. The later whole-document predicate remained false in both runs, so the observed gap is incomplete range/required-anchor/title completion within the genuine deep read, not missing checkpoint provenance.
grounded-board-resolutionFAILPASSPASSFixed by this cut. Structured search followed by the retained deep-read projection produced supported, cited claims in both runs.
grounded-regulatory-agreementFAILFAILFAILSearch ran but produced no admissible grounding evidence. The gate output cannot distinguish genuine corpus absence from retrieval precision/empty-result behavior; no document read reached this projection path.
bait-section-810FAILFAILFAILsearch_knowledge ran, but its result did not satisfy unchanged structured-search provenance. This is a search-result path; the bounded output does not distinguish a zero-result response from another structured-result mismatch.
bait-dollar-capFAILFAILFAILThe agent routed through search_matters and, on confirm, unauthorized search_matter_documents calls instead of beginning with search_knowledge. This is tool routing/auth context, not document-read provenance.
bait-liquidated-damagesFAILFAILFAILThe first run used matter tools without search_knowledge; the confirm reached search_knowledge only after an unauthorized matter-document call and still lacked structured search provenance. This is routing plus search-result quality, not the read projection.
bait-default-notice-daysPASSPASSFAILStructured provenance remained admissible. The confirm instead rejected a specific unsupported “immediate Event of Default” claim, showing answer/judge variance outside the projection seam.