Agent Loop (Harness)
Runs the standard AI step-by-step loop: ask the model, call a tool, repeat until done.
You have no built-in LLM conversation loop unless you use CLI Executor or Procedure Executor instead.
Every model turn is checkpointed, resumable after a crash, budget-checked, and automatically halted if it loops.
What It Does (In Plain English)
Harness is the main loop that talks to an LLM API (like OpenAI, Claude, or Gemini). On every turn it builds the agent’s context, asks the model what to do next, sends tool calls through the safety gateway, trims long histories so you stay within token budgets, and stops the agent if it gets stuck repeating itself.
Real-World Example
- 1A task arrives: "Check why order #402 failed."
- 2Harness gathers allowed instructions and asks the LLM for the next step.
- 3The LLM asks to call the
orders.gettool; Harness runs it through Tool Gateway and saves a checkpoint. - 4Once the LLM has enough facts, Harness submits the final answer through the completion checks.
When Should You Turn It On?
Include in almost every AI workspace (pick ONE executor per workspace: harness, cli-executor, or procedure-executor).
Safety level note: Level 1 · Review — Read-only. Can inspect and answer, never changes outside systems.
How to Add It (workspace.yaml)
kits:
- "@neusym/kit-harness@0.1.0"
kitConfigs:
harness:
maxSteps: 20
loopRepeatThreshold: 3Kits It Works With
Technical Details & Configuration Options (12 settings)
| Package | @neusym/kit-harness |
|---|---|
| Provides Ports | executor@1 |
| Requires Ports | model@1tools@1tasks@1 |
| Optional Ports | budget@1secrets@1model-router@1blobs@1releases@1 |
| Publishes Events | model.called |
| Owned DB Collections | agent_defsrun_manifests |
Configuration Options (kitConfigs.harness)
| Setting | Type | Default | Description |
|---|---|---|---|
maxSteps | integer | 20 | — |
loopRepeatThreshold | integer | 3 | — |
maxTokenRequeues | integer | 10 | Times in a row a run's step may be requeued on a transient refusal (other runs hold the tokens or cost its model call needs, TOKENS_RESERVED, or a guard commit kept losing races with them, GUARD_COMMIT_CONFLICT) before the task is halted (REQUEUE_LIMIT_EXCEEDED). |
maxSeenToolChars | integer | 4000 | Compacts previously-seen tool messages longer than this many characters in outbound model prompts (0 disables trimming; full results remain in checkpoints). |
synthesizeOnMaxSteps | boolean | false | When true, reaching maxSteps runs one final tools-off synthesis call (still subject to step guards and completion gates) instead of immediately halting. |
billingMode | string | "local" | Controls whether this harness charges model calls to the local budget kit ('local') or delegates per-call reservations and settlement to an external proxy ('external-proxy'). |
maxParallelToolCalls | integer | 1 | Maximum number of contiguous parallelSafe read tool calls executed concurrently in a single live turn (1 disables parallel batching; capped at 4). |
maxAttachmentBytes | integer | 10485760 | Maximum byte size of a single hydrated multimodal blob attachment sent to model@1. |
maxContextTokens | integer | 0 | Soft token budget for outbound model prompts; when exceeded, older seen turns are folded into a compact summary while checkpoints retain full history (0 derives 75% of model contextWindow when known). |
keepRecentTurns | integer | 2 | Number of most recent assistant+tool turns kept intact during token-budget context compaction. |
watchdogIntervalMs | integer | 5000 | How often (ms) an in-flight model call polls the kill switch, shared budget scope, and run claim epoch to abort mid-flight via AbortSignal (0 disables polling). |
maxCompletionRetries | integer | 0 | How many times a non-terminal task.complete refusal (e.g. TASK_CRITERIA_UNMET, GOAL_CRITERIA_UNMET, MISSING_COMPUTED_EVIDENCE) is fed back to the model for another attempt while steps remain (0 keeps legacy terminal fail). |