Architecture · Decision record 0015
ADR 0015: Deep research, specificity and long-horizon plans
On this page
- Status: Accepted
- Date: 2026-11-25
- Builds on: ADR 0002 (quarantined reader), ADR 0006 (planner, orchestrator, critic), ADR 0007 (durable runs from the event log), ADR 0012 (crawl engine), ADR 0013 (evolving playbooks)
Context#
A live custom-goal run for "I want to achieve nike's marketing and agentic work" produced a brief whose workstreams were padded with encyclopedia definitions ("Marketing is the act of acquiring, satisfying and retaining customers…", "An AI agent can make decisions…") and whose actions were shallow ("Run a company-xray on Nike…"). Every claim was cited and the critic passed it, because the claims were true and their quotes supported them. The problem was relevance, not support: research_topic searched Wikipedia for the bare topic words, the reader extracted the topic intros faithfully, and nothing in code or in the critic asked whether a claim was about the target. Separately, Company X-ray citation accuracy sat at 71–86% on live runs: compound claims failed as a whole when one half was unsupported, and claims that stayed half-supported after a fix were published as "weak".
Research was also one-shot. The crawl frontier already knows dozens of pages it never read (newsroom, careers, investor and help pages), but after the first draft nothing went back for them. The planner produced a flat step DAG; a long goal had no way to say "research, then draft, then verify" with budgets per stage, and a replan could add a side-effecting step without anyone approving it again.
All of this has to fit the production envelope: Vercel functions of 300 s with durable resume, hard deadlines (custom goal 230 s), and a $0 keyless model chain addressed by role.
Decision#
- Specificity is a code check first.
agent/classifies a claim asspecificity.ts specificorgenericdeterministically. A claim is specific when it names the target (company name or domain stem, accent-folded, word-bounded) or refers to it anaphorically ("the company", "it", "das Unternehmen", …) from a source about the target. It is generic when it does not name the target and (a) its first sentence is definitional ("X is a/the …", "refers to", and basic German, French, Spanish, Portuguese, Italian and Dutch forms), (b) its subject is a generic concept ("An agent can …", "Companies often …", "In general …", or explicitly framed as "Context:"), or (c) every cited source is a reference article not about the target (a Wikipedia topic intro). Goals without a target entity keep concrete practice claims (numbers, named tools) and drop definitions. Sources owned by the target (company site, its GitHub, its feed, connectors) count as about the target. - Generic claims become context or disappear, visibly. Custom goal: generic findings and risks move into a
contextnote capped at two cited lines; the rest are dropped with acritic.flaggedevent that states why. Company X-ray: generic claims are removed (a section left empty says "only general background was drafted"). The critic (v2) additionally returnsaboutTargetper claim; a claim the critic judges not about the target, and that does not name it, is removed from the deliverable and, for goals, demoted to context. Each deliverable carriesverification.specificity= specific ÷ (specific + generic) over drafted claims, with counts moved and dropped, next to citation accuracy. - Topic research asks about the target.
research_topicnow takesresolve_targetas input and searches Wikipedia for "<company> <topic>", keeping only articles whose title or intro mention the company. General topic intros are fetched only when nothing about the company matched, and the specificity check above confines them to the context note. The reader task asks for facts about the company and to skip textbook definitions. - Deep research is a bounded loop after the first draft.
missions/runs rounds of: coverage analysis (sections with fewer than two supported claims are thin), gap analysis by theshared/ deep-research.ts plannerrole (deep-research.gaps.v2), targeted follow-ups, quarantined reading, and a redraft. Candidates are built by code from what research already discovered: unread crawl-frontier pages (served from the crawl cache when already fetched), the feed, the GitHub organisation, the Wikipedia/Wikidata entry, and target-plus-topic reference searches. The model only picks candidate ids (C1…) and section ids (T1…); unknown ids are ignored. No free text from a crawl or a model reaches the gap planner: each lead is shown as{id, kind, host, pathDepth, topic}and each thin section as{section, topic, supportedClaims}, wheretopiccomes from the fixed vocabulary of the crawl URL classifier (COMPANY_PROFILEtopics, elseunclassified), so a crafted path or a model-written workstream name can at most change which allowed lead is picked (v1 showed sanitised paths and names as labels). Every fetch goes throughexecuteToolCallwith the step's own grant and the policy engine, and every page through the quarantined reader. If the planner is unavailable or too slow, candidates are ranked by keyword overlap with the thin sections. The loop stops on coverage, round cap (2), no candidates, no new evidence, or the time budget:MissionClock.fitsfor planner + reader + redraft + critic, and for custom goal also the hard deadline minus a 45 s critic reserve; a deadline abort mid-round ends the loop cleanly instead of failing the run. Custom goal and X-ray run it asdeepen_researchaftersynthesise; the audit runs it before the department analysts, with lens fact counts as coverage and no redraft. The pre-draftfill_gapsagent loop is unchanged (its red-team cases still apply); deep research reuses its tools, reader and frontier throughResearchKit.followUps. Rounds are recorded instep.completed.payload.research(thin sections, leads, who selected them, facts gained, coverage before and after, stop reason) and in anagent.messageper round, and copied into the deliverable's verification block. - Actions must be grounded and concrete. A goal action now needs cited evidence (
basis), afirstStepof at least four words that is not a vague verb ("explore options"), a measurablesuccessMetric(a number, rate, time or count), an owner role, effort and impact. Code rejects actions whose title only says to run a Delegate mission ("Run a company-xray on Nike") unless they add scope, and actions whose evidence is generic background. Audit opportunities gainownerandsuccessMetric; a missing metric falls back to the ROI estimate, labelled as an estimate; vague first steps are rejected and replaced once, as other generic candidates already were. - The critic fixes claims, not paragraphs. The editor (v2) receives the critic's supported and unsupported atoms per claim and must return the exact supporting span for each rewrite; code checks the span against the cited quotes and rejects the rewrite if it is not there. Compound claims may be split into up to three parts, each rechecked and kept or dropped on its own (
keptPartsmaps parts back into sections). A claim that is still only partly supported after a fix attempt is removed; a claim never sent to the editor (no time) stays "weak", as before. Reports addpublishedAccuracy(share of published, checked claims that are fully supported) andsplit;citationAccuracykeeps its formula ((supported + fixed) ÷ checked, removed claims count against it), so the headline number stays comparable with earlier runs. - Plans can have two levels. A plan may carry
phases(id,objective,budgetShare,dependsOnon earlier phases only) and each step aphase.validatePhases(insidevalidatePlan/checkPlanSteps) enforces: every step in a known phase, no inputs from later phases, phase shares sum to at most 1 and cover their steps' shares, at most five phases. When the planner names a mission's default phases but omits the list, the defaults are adopted with budgets recomputed from the steps. The orchestrator runs phases in order and steps within a phase in parallel. At a phase boundary, a finished step that reportsneedsReplantriggers a planner revision even above the confidence threshold. Custom goal plans are phased by default (research → draft → verify); planner v3 explains phases. - Approval covers what was approved.
revisionApproval(approved, revised)marks a revision as needing approval when it adds capabilities the approved plan did not hold, or gives a side-effecting capability (SIDE_EFFECT_CAPABILITIES) to a step that did not have it. Such a revision is emitted asplan.revisedwithrequiresApproval: true(the fold marks the plan unapproved) and goes to the same plan-approval waiter askind: "revision", required: true(the first plan goes askind: "initial"). A required revision is never auto-approved by the guest auto-approve cookie, the workspaceautoApprovePlanssetting or an Autopilot child policy ofplan: "auto": those settings cover the first plan only, and a widening revision always waits for a human click. If nobody decides before the plan-approval timeout, the revision is rejected and the run continues on the plan approved earlier. Approval emitsplan.approvedfor the new version, rejection emits a revertingplan.revised(sourcereviewer) and aplan.approvedthat restores the earlier plan. Revisions within the approved capabilities proceed without asking. Runs without a reviewer attached (evals, CLI and direct runtime calls; every web, API and MCP run goes throughexecuteRun, which always attaches the waiter) auto-approve with a reason that names the added capabilities, exactly as the first plan is auto-approved. Tool-level approvals for side effects are unchanged. - Prompts are new versions.
critic.v2,editor.v2,planner.v3,custom-goal.synthesis.v2,company-xray.synthesis.v2,automation-audit.analyst.v2and the newdeep-research.gaps.v1, each with achanges:header (now an accepted optional header field). Earlier versions stay for replays and eval baselines. - Playbooks learn the new signals. Lesson kinds
specificity("N generic background claims were moved or dropped") andresearch("deep research added N facts in R rounds; coverage a% to b%", or why it stopped) are derived from the structured reports only, never from claim text.
Consequences#
- Briefs get shorter before they get better: on a thin evidence base, generic padding is now removed rather than shown, and the brief says so. That is the intended trade; the context note keeps two lines of background where it helps reading.
- On the repository fixtures, the custom-goal brief's drafted specificity is 75% (6 of 8 claims; the two topic definitions go to context) and its published claims are 100% specific; the X-ray fixture drafts 8 of 9 specific claims and publishes none of the generic one. The critic fixture (20 claims: 12 supported, 4 half-supported compound, 2 cross-source compound, 2 unsupported) moves from 60% citation accuracy and 60% supported published claims under the v1-style loop to 90% citation accuracy and 100% supported published claims. These are scripted-model fixtures; live accuracy depends on the keyless chain and is measured by the eval harness.
- Deep research costs up to two extra planner calls and one redraft per round. It is skipped automatically on slow or throttled chains, so a $0 run degrades to the previous single-pass behaviour rather than timing out.
- The deterministic classifier is conservative and language-basic. It can miss a generic claim phrased unusually, which the critic's
aboutTargetjudgement then catches; it can also treat a common-word brand stem as a mention. Both are visible incritic.flaggedevents and in the specificity score. - A phased plan serialises phases, so a step cannot start early even if its inputs are ready. Missions keep flat plans unless phases buy a real checkpoint.
- Mid-run re-approval can pause a run waiting for a reviewer; the durable resume path already handles a run that is waiting on plan approval, and a revision the reviewer rejects leaves the approved plan running.
Addendum (2026-11-25): repairing grounded output instead of losing it#
The first live gate pass after this ADR (NVIDIA free chain, one trial per case) failed four cases on counts, not on truth: repo X-ray kept 1 and 3 improvements (an invented tests/ directory in a repo whose tests live in test/, and four items that did not match the improvement schema), two goal briefs kept 2 of 3 actions (a definitional basis for a topic-only goal; bases that cited only reference articles for a company goal, and a deep-research redraft that replaced a 3-action draft with a 2-action one), and two audits kept 3 and 2 opportunities (the editor picked exactly 5, the critic then dropped 2 or 3, and a gov.uk/ seed crawled the whole of gov.uk). The rules stay; what changes is that code now gives the model one chance to satisfy them and keeps more candidates in reserve.
- One review-and-repair turn for grounded output.
callStructuredReviewed(agent/) runs the usual parse-and-repair call, applies a code review (normalise, ground, count) and, when the review rejects too much, sends one more turn listing every rejected item with the code's reason. It keeps the better of the two answers by the review's score, so a worse or invalid revision never replaces a usable answer, and skips the turn when the mission clock says there is no time. Used by the repo improver (fewer than 5 valid improvements; reasons include schema issues, unknown paths and the repo's real test directories) and the goal synthesis (fewer than 3 grounded actions; reasons include the specificity verdict and, for a company goal, which source ids are about the target).structured.ts repo-xray.improver.v2receives the file list and test directories;custom-goal.synthesis.v3carries a worked action and the basis rule. A deep-research redraft is kept only if it grounds at leastmin(previous, 3)actions. - Audit reserves. The editor's best unpicked candidates (enough to reach 8 in total, and at least 4) are checked by the critic in the same pass as the picked ones; when picked opportunities are dropped, verified reserves backfill up to the minimum of 5, ranked by estimated value with the rest.
- Stated shortfall. When fewer than 5 opportunities survive, the audit carries
shortfall{found, minimum, reason} and its summary says the public evidence was insufficient and that nothing was padded in. The eval hard check stays 5-8 (seepackages/); the soft checkevals/ datasets/ README.md shortfall_flaggedgrades the honesty of the statement. - Focused crawl for a section seed. When the input URL is a section of a host (a path other than the root or a bare locale), the crawl drops sitemap URLs outside that path, boosts the section and pages it links to, and reads focused pages first. Same-host scope and politeness are unchanged.
- Organisations before places. The goal target resolver prefers a Wikidata entity with organisation properties (industry, headquarters, employees, parent, legal form) over a place with the same label and a website.