Skip to content
Français

createHarness

import { createHarness } from "@elie-laloum/outpost";

Compose the built-in harness: Outpost runs the model loop itself, calling the model provider once per step and running tools through the borrowed sandbox. Options are validated immediately and unknown keys are rejected; nothing runs until an agent from createAgent({ harness, model }) is dispatched.

Complete example and detailed rules.

  • optionsRequired
    HarnessOptions
    Settings of the built-in harness: model provider, instructions, tools, limits, tool execution, hooks, permissions, context strategy, skills, conversations, caching and MCP servers.
  • options.routingOptional
    HarnessModelRouting | undefined
    Optional per-step routing declared with defineHarnessModelRouting; all candidates use this harness model provider.
  • options.modelProviderRequired
    ModelProvider
    Model provider called for every step and summary request, such as createOpenAIModelProvider() or createAnthropicModelProvider(). Its validate() checks the agent model when createAgent() composes the agent.
  • options.instructionsOptional
    HarnessInstructionsOption | undefined
    System instructions as text, a defineHarnessInstructions() or defineMcpPrompt() result, or a list of these. Resolved at each turn and joined with blank lines; empty results are skipped.
  • options.toolsOptional
    readonly (HarnessTool<unknown> | HarnessToolset)[] | undefined
    Tools and toolsets the model may call. Nested toolsets are flattened; names must be unique across the harness, including skill and MCP tools.
  • options.limitsOptional
    HarnessLimits | undefined
    Bounds per turn on steps, tool calls, delegation depth and token usage. Exceeding a bound fails with code limit.
  • options.toolExecutionOptional
    HarnessToolExecution | undefined
    Tool concurrency, per-call deadline and error policy.
  • options.hooksOptional
    readonly HarnessHook<HarnessHookPhase>[] | undefined
    Hooks from defineHarnessHook, run in declaration order within each phase.
  • options.permissionsOptional
    HarnessPermissions | undefined
    Rules from defineHarnessPermissions(), evaluated before before-tool hooks. They also apply to every subagent’s tool calls.
  • options.contextOptional
    HarnessContextStrategy | undefined
    Strategy that can rewrite the history before each model request, such as truncateToolResults() or summarizeHistory().
  • options.conversationsOptional
    false | ConversationStore | undefined
    Store for turn transcripts, default createHarnessConversations() under .outpost/conversations/harness in the repository. Wrap it with createTransportConversations() for remote storage; false disables capture, continuation and response repairs.
  • options.skillsOptional
    readonly HarnessSkill[] | undefined
    Skills listed in the system instructions and loaded on demand through the load_skill tool; duplicate skill names are rejected.
  • options.cacheOptional
    boolean | undefined
    Asks the model provider to cache the conversation prefix on each request, default true. The Anthropic provider marks the prefix for caching; OpenAI caches stable prefixes on its own.
  • options.mcpServersOptional
    McpServers | undefined
    MCP servers keyed by name, started inside the borrowed sandbox for each turn; their tools appear as mcp__<server>__<tool>, plus resource and prompt tools when servers offer them. The lease must support liveInput, and oauth: “login” servers are rejected.

Harness

export declare function createHarness(options: HarnessOptions): Harness;