Skip to content

harness: keep the Inquiry orchestrator context bounded (delegate to isolated per-tick sub-agents + artifacts, don't accumulate) #260

Description

@ccisnedev

Motivation

A core goal of Inquiry is to need much less context than freestyle: the main inquiry agent should only orchestrate (run iq commands, dispatch), while each sub-agent handles one task in its own context window and persists results as artifacts (.md docs, modified code). The harness should not depend on how large a context window the model has — investigation lives in files (Memory as Code), not in the chat.

Today that goal is not realized: the orchestrator's context grows with the cycle and saturates the window.

Evidence (measured, real agent=inquiry + qwen3-coder:30b-16k session)

  • Orchestrator context grows monotonically within one cycle: tokens.input 7,252 → 7,679 → 8,799 → 9,805 → 11,215 → 12,466 → 13,644 → 14,578 → 16,370 (nearly the 16,384 ceiling) over ~22 turns.
  • The orchestrator did work in its own context (it should only run iq): bash×7, read×5, write×2, skill×3, task×4. It investigated and edited code directly instead of delegating — violating the firmware contract ("never implement yourself; orchestrate via CLI only").
  • Sub-agent isolation already works: the dispatched sub-agents ran as separate sessions with their own windows (max tokens.input 6,107 / 6,108 / 16,383). The mechanism to run a task in an isolated context exists on this host (OpenCode).

Diagnosis

The isolation primitive exists, but the orchestrator is not bounded because:

  1. Discipline: the model performs direct work (bash/read/write) in the main context. The firmware forbids it but does not enforce it.
  2. Structure: full history accumulates turn over turn, and sub-agent return values flow back into the orchestrator context. There is no compaction and no fresh-context-per-tick. So cycle length, not task size, fills the window.

Scope to investigate / implement

  • Enforce orchestrator-only behavior: the orchestrator runs only iq commands — no direct bash/read/write/edit (push all of it into sub-agents).
  • Minimal sub-agent return contract: sub-agents return a pointer to the artifact (e.g. diagnosis.md, file path), not their full output, so little re-enters the orchestrator context.
  • Per-tick fresh context: each FSM transition re-derives state from iq fsm state --json and the on-disk .md artifacts rather than carrying conversation history; evaluate OpenCode session compaction.
  • Measurable goal: orchestrator tokens.input stays roughly constant (~firmware 1.6k + current state), independent of cycle length and of the model's context window.

Relationship to #259

#259 ensures the model has enough context (provisioning, ≥16384). This issue reduces how much context the harness needs in the first place. Complementary; this one is the deeper, methodology-level goal.

Found while QA-ing the OpenCode harness on a local model (#247, #257, #259).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions