Skip to content

Add background investigation scout step before planning #3885

Closed

Description

@senamakel

Summary

Add a "background investigation" (scout) step before planning: one cheap researcher pass grounds the planner with a handful of real snippets so the resulting plan is anchored in current facts rather than the model's priors.

Problem

Our planner plans blind — it decomposes from the prompt alone. Plan quality improves markedly when the planner has seen a few relevant results first (correct entity names, current facts, scope of the space). deer-flow runs a background investigation before the planner node for exactly this reason.

Solution (optional)

Scope: core.

  • Optional pre-planner step: a single cheap researcher (web/doc) call, results fed into the planner prompt as grounding context.
  • Gate behind config + a heuristic (skip for trivial asks, or when #2's has_enough_context would already fire).
  • Keep it bounded — one call, capped result size, summarized into the planner prompt.
  • [scout] logging on invoke / skip / inject.

Acceptance criteria

  • Scout step — optional grounding pass runs before planner when enabled.
  • Grounding injected — scout results reach the planner as context.
  • Bounded & gated — single capped call, config-gated, skipped for trivial asks.
  • Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate.

Related

Part of a deer-flow parity set (harness improvements 1–6). Composes with #3882 (skip scout when context already sufficient) and feeds better plans into #3881.

Implementation Plan

Triage Assessment

  • The planner builtin agent doesn't receive pre-grounded context: it decomposes the task solely from the user prompt.
  • A context_scout subagent exists (src/openhuman/agent/harness/subagent_runner/ops/prompt.rs:39-46) but runs inside the orchestration graph as a per-session subagent, not before the planner.
  • Issue Add has_enough_context early-exit flag to the planner #3882 (has_enough_context early-exit, closed as completed) already provides the heuristic gating.
  • User impact: planner produces better plans (correct entity names, current facts, accurate scope).

Proposed Scope

  • In-scope:
    1. Define a pre-planner scout step: before planner runs, make one bounded researcher/doc call.
    2. Feed summarized results into the planner's instruction context (not injected into the conversation as turns).
    3. Gate behind a new scout_before_plan config flag + the existing has_enough_context heuristic from Add has_enough_context early-exit flag to the planner #3882.
    4. Add [scout] tracing on invoke / skip / injection.
  • Explicit non-goals:
    • Not building a new web search agent (reuses existing researcher builtin agent at src/openhuman/agent/harness/builtin_definitions.rs:265).
    • Not adding a multi-call investigation loop (single capped call).
    • Not changing the planner's internal decomposition logic.

Implementation Steps

  1. src/openhuman/agent/harness/grounding_scout.rs — New module. Define GroundingScout struct with:
    • invoke(ctx: &ScoutContext) -> Option<String> — spawns the researcher subagent with the user prompt, caps tool calls at 1, caps result length at ~2000 chars, summarizes the output. Returns None if skipped (config off, trivial ask, or has_enough_context true).
    • Config check from Config::agent().scout_before_plan (add to config schema in src/openhuman/config/schema/).
    • Trivial-ask heuristic: skip if prompt length < 50 chars or is a known-simple pattern (yes/no, greeting, confirmation).
  2. src/openhuman/agent/harness/mod.rs — Add pub mod grounding_scout;.
  3. Planner prompt injection — In src/openhuman/agent/harness/subagent_runner/ops/prompt.rs, before building the planner's base prompt, call GroundingScout::invoke. If it returns Some(summary), prepend the summary to the planner's instructions (e.g. "[Background context from research:\n{summary}\n---]").
  4. Config gate — Add to src/openhuman/config/schema/agent.rs:
    pub scout_before_plan: bool, // default false
    Wire env override in src/openhuman/config/schema/load.rs.
  5. Logging — In GroundingScout::invoke, emit tracing::debug!(target: "scout", "[scout] invoke|skip|inject ...") on each path.
  6. Test the scout — Add #[cfg(test)] mod tests in grounding_scout.rs:
    • scout_invokes_researcher_when_enabled — mock the subagent runner, assert researcher is called.
    • scout_skips_when_disabled — config off, assert no call.
    • scout_skips_trivial_ask — prompt "yes", assert no call.
    • scout_skips_when_context_sufficient — reuse has_enough_context logic, assert skip.
  7. Planner prompt test — Add test in src/openhuman/agent/harness/subagent_runner/ops/prompt.rs or a new test file verifying scout summary appears in planner's built instructions.

Verification

Risks and Open Questions

  • The scout adds one LLM call (the researcher) and one tool call. Even capped, this adds latency to every planning turn. The config default should be false.
  • What happens when the researcher returns empty results for a novel domain? The planner gets an empty grounding context, which is equivalent to today's behavior — acceptable.
  • The existing context_scout subagent may overlap partially. Ensure the pre-planner scout is a different point in the flow (before planner decomposition, not during orchestration execution).
  • If the planner prompt already contains sufficient context from the conversation transcript, the scout adds no value. The has_enough_context heuristic should be the primary gating signal.

Acceptance Criteria

  • Pre-planner scout step runs when scout_before_plan = true and has_enough_context is false.
  • Scout results are injected into the planner's instruction context.
  • Single capped researcher call, results summarized to ≤2000 chars.
  • Config-gated with default false.
  • Diff coverage >= 80%.

Activity

  1. added
    feature
    agent
    on Jun 22, 2026
  2. ssmadhavan006 commented on Jun 23, 2026

    @ssmadhavan006

    Hi, I'd like to work on this issue.

    My understanding is that the goal is to add a lightweight, optional scouting step before planning so the planner can be grounded with a small amount of real context instead of planning solely from the user prompt.

    My current idea is to keep it bounded to a single researcher/search pass, gate it behind configuration and existing context checks, and inject a summarized version of the findings into the planner's context. I'll also make sure the scout step can be skipped when the request is trivial or sufficient context is already available.

    Before I start implementing, does this direction align with what you had in mind, particularly around where the scout should live in the planning flow?

    Happy to take this on if nobody else is working on it.

  3. YellowSnnowmann commented on Sep 11, 2026

    @YellowSnnowmann
    Member

    Verified on main (6be58a9) — unimplemented, but every building block already exists. This is wiring, not new machinery.

    @ssmadhavan006 — your direction is right, and your open question ("where should the scout live in the planning flow?") has a fairly concrete answer in the current tree. Findings:

    1. The planner still plans blind. src/openhuman/agent/registry/agents/planner/ (prompt.md, prompt.rs, agent.toml) contains no mention of scout, grounding, or background investigation. It decomposes from the prompt alone, exactly as the issue says.

    2. context_scout exists and is already a first-class agent — confirming the triage note. src/openhuman/agent/harness/subagent_runner/ops/prompt.rs:42-49:

    context_scout defines its own strict output contract (emit a single … ) … Skip the suffix for the scout; its prompt.md …

    It is handled specially precisely because it has a strict output contract, which is what makes it safe to consume programmatically. You should not need to write a new researcher agent.

    3. The #3882 gating heuristic is live and reusable. has_enough_context exists as a real field, not just a concept:

    • src/openhuman/agent/harness/fork_context.rs:167 — pub has_enough_context: Option<bool>
    • src/openhuman/agent/orchestration/tools/agent_prepare_context_part_01.rs:66 — the folding logic across prepared sources
    • src/openhuman/agent/harness/session/turn/core_turn.rs:535

    4. There is already a prepared-context bundle abstraction — agent_prepare_context produces sources carrying both has_enough_context and recommended_tool_calls, and already_prepared_context_bundle() (agent_prepare_context_part_01.rs:56+) renders a no-op result when context was prepared earlier, with an explicit sufficiency note.

    What that means for the design

    The three acceptance criteria map onto existing seams rather than new ones:

    criterion existing seam
    Scout step runs before planner when enabled invoke the existing context_scout agent
    Grounding injected into the planner the prepared-context bundle already has a render path into a prompt
    Bounded & gated, skipped for trivial asks has_enough_context from #3882 is the gate

    So the answer to "where should it live" is most likely the prepared-context path, not a new node — agent_prepare_context is already the thing that gathers grounding and reports sufficiency, and the gap is that the planner does not consult it. Framing the work as "make the planner consume a prepared-context bundle, and run the scout to populate one when it is missing and the ask is non-trivial" reuses all four pieces above and keeps the bounded/gated requirement essentially free.

    Worth confirming with a maintainer before you start, since this touches the orchestration graph — but that framing should make the scope much smaller than the issue implies.

    One thing to watch: context_scout's strict output contract is what the prompt.rs special-case protects. If the scout output gets summarized into the planner prompt, make sure the summarization does not re-introduce the generic headings that special-case exists to avoid — the comment at prompt.rs:45-47 is describing a failure that has already happened once.

    Leaving open and unassigned as far as I can tell — @ssmadhavan006 asked in June and has had no reply, which is probably the main thing blocking this.

  4. added
    triage: needs-opinion
    on Oct 9, 2026
  5. senamakel commented on Oct 9, 2026

    @senamakel
    MemberAuthor

    Triage: needs opinion — “Add background investigation scout step before planning” needs a maintainer decision on product scope/priority or fresh reproduction evidence before its status can be settled. Please advise whether to pursue, narrow, or close it.

  6. added
    source: team
    on Oct 9, 2026
  7. M3gA-Mind commented on Nov 16, 2026

    @M3gA-Mind
    Collaborator

    Thanks for this, and @ssmadhavan006, thanks for offering to take it. The agents this plan connects have since been removed: the planner and context_scout sub-agents went in #6760 and #8319, and planning now happens in plan mode with request_plan_review. So this issue can't be done as written, and we're closing it.

    The idea itself, grounding a plan with a quick look first, still makes sense. If you'd like to pursue it, please open a new issue proposing where a scout step would fit in plan mode, and a maintainer can confirm the approach before you start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentfeaturesource: teamtriage: needs-opinion

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions