Skip to content

Implement ai.harness - #341

Draft
anbuzin wants to merge 4 commits into
mainfrom
implement-harness
Draft

anbuzin wants to merge 4 commits into
mainfrom
implement-harness

Conversation

@anbuzin

@anbuzin anbuzin commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

A coding agent on top of ai.Agent, for long-running processes. The loop
is the standard loop plus:

- a built system prompt: env facts, AGENTS.md files, a skill list
- steering: before each model request, and before stopping, the loop
  awaits the `steer` hook; the interface answers with its queued
  messages (possibly none)
- turn and token limits
- compaction by a client-side summary

Tools: read, bash, and task (runs a subagent that cannot nest or
steer). `python -m ai.harness` is a stdlib REPL to try it.
Interrupts: the interface cancels the run's task. The loop adds the
partial turn before the cancel goes on: the text so far, the finished
tool results, and an "Interrupted by user" error result for every
other tool call whose ToolEnd it saw. Every tool call needs a result,
or the next run would replay (re-run) it. Interrupt and redirect is a
new run on that history; the REPL starts it with the lines typed
during the stopped run.

Budgets: MAX_TOKENS and the new MAX_USD cover a run and its subagents.
The top-level run puts a Budget in a contextvar; subagent runs add to
it and stop at the same limits. A request counts when its stream ends,
so subagents started by the turn see it. MAX_USD is best-effort, from
models.dev prices, and raises UnknownCostError when the model has no
prices or a request reports no usage. LimitReached gains "usd" and
reports the shared totals. The REPL gets --max-usd and keeps the
session on any AIError.
Move PROMPT, SUMMARY_PROMPT, SUMMARY_PREFIX and the system message builder
to ai.harness.prompts, and Steered, Compacted, LimitReached to
ai.harness.events. The system message is now built by callers with
prompts.system_message(). Rename task -> subagent and usd -> to_usd.
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ai-python Ready Ready Preview, v0 Nov 5, 2026 8:43pm UTC

@vercel-internal-security-reviewer

Copy link
Copy Markdown

Security review details

This branch was successfully deployed

1 active deployment
Preview — 9c631e13 Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant