Spec: 119-query-aware-agent-harness.
Status: experimental, behind featureFlags.queryAwareHarness.
The Shep Harness is a shep-owned agent loop. It is exposed as the agent type
shep-harness, so every feature node can run on it through
IAgentExecutorProvider. It runs on any SDK backend: OpenRouter, Together AI,
Ollama or LLMProxy.
It differs from a transcript agent in two ways:
ContextPlan. The context
engine decides how much of each chunk this query needs (hidden, short, long
or full), renders views from the stored raw content, and fits them to the
budget. Nothing is concatenated from earlier turns.| Layer | Where | What |
|---|---|---|
| Domain | packages/core/src/domain/harness/ |
visibility ladder, task state machine, budget fitter, permission precedence, fingerprints, prompt sections, default config |
| Ports | application/ports/output/harness/ |
blob store, event log, repositories, model provider (+ factory), decision provider, tool source/executor, policy engine, command inspector, instruction source, workspace, project setup, eval suites/workspaces |
| Services | application/services/harness/ |
HarnessRuntime (query-aware and baseline loops), HarnessTaskService (sessions, config, structured output), context engine and candidate retriever, renderers, decision service, capability registry and router, permission service, tool invoker, session restorer |
| Use cases | application/use-cases/harness/ |
run / resume / stop / apply / promote / discard, session detail, context plan, chunk view, explain, include-from-next-turn, permissions, capabilities, policies, init, events, evals |
| Infrastructure | infrastructure/services/harness/, infrastructure/repositories/harness/ |
SQLite JSON-document repositories (migrations 148–151), file-system blob store, git snapshotter and worktree workspaces, builtin tools, YAML policy engine and shell inspector, decision providers, AI SDK model provider, eval suites |
| Presentation | src/presentation/cli/commands/harness/, src/presentation/web/{app/harness,components/features/harness} |
shep harness …, /harness, the feature drawer’s Context tab, permission prompts, the Agent Harness settings |
tests/unit/architecture/harness-dependency-rule.test.ts enforces these
dependency rules:
fullTokenCap (default 4,000) get their long view unless
the agent calls expand_chunk.use_capability, expand_chunk, complete_task) plus the tools loaded
so far.
use_capability with args loads a tool and calls it in the same turn.ask waits for a person (web, CLI) or, when non-interactive,
resolves to deny. A grant can cover once, a task (a feature phase) or
the session.Baseline mode is the reference loop: an append-only transcript with every tool schema loaded. Shadow context routing runs baseline and also persists the query-aware plans it would have used.
tests/integration/evals/harness/):
Set SHEP_EVAL_REPORT_DIR to get JSON reports.
shep harness eval run smoke, or /harness → Evals) runs
the same tasks on both modes in throwaway repositories. For each it reports:
On tiny tasks query-aware costs slightly more input: its system prompt is larger and there is little transcript to save. On long tasks with large tool output it saves most of the input. See the paired-eval integration test for both cases.