Skip to content

feat(harness): add sandbox specific expansion for harness abstraction, add sandbox-just-bash and sandbox-vercel - #15919

Merged
felixarntz merged 6 commits into
mainfrom
fa/add-harness-sandbox-abstraction
Jun 9, 2026
Merged

feat(harness): add sandbox specific expansion for harness abstraction, add sandbox-just-bash and sandbox-vercel#15919
felixarntz merged 6 commits into
mainfrom
fa/add-harness-sandbox-abstraction

Conversation

@felixarntz

@felixarntz felixarntz commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Background

This is the first PR broken out from #15496, the harness abstraction layer. All code in these new packages is considered experimental.

Summary

  • Implement the harness specific expansion of the sandbox abstraction, called HarnessV1NetworkSandboxSession. Its shape is driven by harness needs (see original draft PR).
    • The type has a restricted() method which returns an (effectively lower-capability) instance of Experimental_SandboxSession. This instance should be passed to tool calls, not the network session instance. Otherwise tools would be able to perform actions that go widely beyond their authority, e.g. stopping the sandbox.
    • Eventually, this could live in provider-utils or specification as an expansion to the existing Experimental_SandboxSession, however we leave it in this experimental package, particularly because it's directly related to the harness abstraction.
  • Implement HarnessV1SandboxProvider, a basically stateless container for sandbox definition. It allows to define a specific sandbox definition in the file root, similarly to e.g. ToolLoopAgent (or the future HarnessAgent). The createSession() and resumeSession() methods are then used to create stateful sandboxes by actually bootstrapping the resource.
  • Implement adapters for just-bash and Vercel Sandbox. These provide both an implementation of Experimental_SandboxSession and HarnessV1NetworkSandboxSession, accessible via the HarnessV1SandboxProvider.

Note: Merging this PR will publish the first canary releases of the new packages:

  • @ai-sdk/harness
  • @ai-sdk/sandbox-just-bash
  • @ai-sdk/sandbox-vercel

Manual Verification

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

@felixarntz
felixarntz merged commit 9d6dbe0 into main Jun 9, 2026
50 checks passed
@felixarntz
felixarntz deleted the fa/add-harness-sandbox-abstraction branch June 9, 2026 15:55
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.0-canary.167 github npm
@ai-sdk/amazon-bedrock 5.0.0-canary.79 github npm
@ai-sdk/angular 3.0.0-canary.167 github npm
@ai-sdk/anthropic 4.0.0-canary.64 github npm
@ai-sdk/anthropic-aws 1.0.0-canary.5 github npm
@ai-sdk/azure 4.0.0-canary.71 github npm
@ai-sdk/devtools 1.0.0-canary.29 github npm
@ai-sdk/gateway 4.0.0-canary.101 github npm
@ai-sdk/google-vertex 5.0.0-canary.105 github npm
@ai-sdk/harness 0.0.0-canary.1 github npm
@ai-sdk/langchain 3.0.0-canary.167 github npm
@ai-sdk/llamaindex 3.0.0-canary.167 github npm
@ai-sdk/openai 4.0.0-canary.70 github npm
@ai-sdk/otel 1.0.0-canary.113 github npm
@ai-sdk/policy-opa 1.0.0-canary.4 github npm
@ai-sdk/react 4.0.0-canary.170 github npm
@ai-sdk/rsc 3.0.0-canary.168 github npm
@ai-sdk/sandbox-just-bash 0.0.0-canary.1 github npm
@ai-sdk/sandbox-vercel 0.0.0-canary.1 github npm
@ai-sdk/svelte 5.0.0-canary.167 github npm
@ai-sdk/tui 1.0.0-canary.2 github npm
@ai-sdk/vue 4.0.0-canary.167 github npm
@ai-sdk/workflow 1.0.0-canary.84 github npm

felixarntz pushed a commit that referenced this pull request Jun 9, 2026
…box-just-bash`, and `@ai-sdk/sandbox-vercel` (#15932)

follow up to #15911 and
#15919

Problem was that we set the version in the initial package.json file to
`"0.0.0-canary.0"` instead of just `"0.0.0"`


https://github.com/vercel/ai/blob/16ff5014109c69679cbef3db35da1d9b036add29/packages/harness/package.json#L3

The [`changeset` CLI](https://www.npmjs.com/package/@changesets/cli) is
using [semver](https://www.npmjs.com/package/semver) to calculate the
next version.

this is the problem
```
semver.inc("0.0.0-canary.0", "major")
// 0.0.0
```

this works as expected
```
semver.inc("0.0.0", "major")
// 1.0.0
```
felixarntz added a commit that referenced this pull request Jun 10, 2026
## Background

After #15919, this is the 2nd breakout PR from the overarching harness
SDK work in #15496.

## Summary

* implement the harness specification v1 that each harness adapter must
implement
* eventually this should probably live in `@ai-sdk/specification`, but
we keep it in its own `@ai-sdk/harness` for now due to the experimental
nature of it all
* implement `HarnessAgent` as consumer-facing entrypoint
`@ai-sdk/harness/agent` for running harnesses
* implement bridge foundation (separate entrypoint
`@ai-sdk/harness/bridge`) which each harness that runs the underlying
SDK inside a remote sandbox uses to communicate with that process in the
remote sandbox
* implement harness adapter utilities (separate entrypoint
`@ai-sdk/harness/utils`), exclusively for harness adapter use
* implement supplementary `HarnessAgent` helpers to fit into existing AI
SDK paradigms where reasonable (e.g. observability)
* a few additional `ai` package exports are added because `HarnessAgent`
lives in this separate package (because it's considered experimental)
* only the `HarnessAgent` layer relies on these exports - the
specification itself rightfully does not have any dependency on `ai`

## Manual Verification

Verification is happening via the original PR #15496.

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
felixarntz added a commit that referenced this pull request Jun 10, 2026
…15969)

## Background

After #15919 and #15941, this is the 3rd breakout PR from #15496.

## Summary

- Implements the harness adapters for Claude Code, Codex, Pi
- Clarifies one harness specification confusion where
`HarnessV1ResumeState` was used for two things (resuming a session _and_
continuing a turn); it is now replaced by two distinct types
- Adds executable code examples for harness in `examples/ai-functions`
- Adds end-to-end surfaces for testing the harness adapters on various
agent configurations:
    - `examples/harness-e2e-next` (Next app)
    - `examples/harness-e2e-tui` (TUI)

## Manual Verification

Run the new `examples/ai-functions` snippets and/or play around with the
two interactive surfaces `examples/harness-e2e-next` and
`examples/harness-e2e-tui`.

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)

## Future Work

Follow-up PRs will add documentation and the workflow specific utilities
so you can use `HarnessAgent` with `workflow`.
@felixarntz felixarntz mentioned this pull request Jun 11, 2026
5 tasks
felixarntz added a commit that referenced this pull request Jun 11, 2026
## Summary

This adds documentation for the new harness abstraction added in #15919,
#15941, and #15969:

- new top-level `harnesses` entry point
- harness adapters section (equivalent to existing providers section)
- two mentions in suitable places in existing docs

## Manual Verification

N/A

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [ ] Tests have been added / updated (for bug fixes / features)
- [x] Documentation has been added / updated (for bug fixes / features)
- [ ] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
felixarntz added a commit that referenced this pull request Jun 23, 2026
…ess agent execution (#16315)

## Background

After #15919, #15941, and #15969, this is the 4th and final production
code breakout PR from #15496.

## Summary

This PR introduces `@ai-sdk/workflow-harness`, a package that lets you
run a `HarnessAgent` turn in a durable
[`workflow`](https://vercel.com/docs/workflow). A long turn is sliced
into short, time-boxed steps. Between slices the agent is frozen
non-destructively — the sandbox keeps running and the next slice
reattaches to the in-flight turn — while a serializable state object is
persisted as the durable step return value.

The package ships plain, framework-independent helpers plus a
serializable state machine; you own the thin `'use workflow'` / `'use
step'` wrappers so that Node-heavy dependencies (the agent, sandbox
provider) stay out of the compiled workflow bundle.

- New `@ai-sdk/workflow-harness` package exposing
`createHarnessWorkflowState`, `runHarnessAgentSlice`, and
`finalizeHarnessWorkflow`, with the `HarnessWorkflowState` machine that
drives slice-by-slice execution and resumption.
- Executable examples for the existing harness adapters demonstrating
non-destructive turn freezing.
- End-to-end workflow examples (route, workflow, and step modules) for
each harness in `harness-e2e-next`.
- New "Workflow Utilities" documentation page under AI SDK Harnesses.

## Manual Verification

Run the workflow examples in `harness-e2e-next` for each harness adapter
(Claude Code, Codex, Pi).

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [x] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
@felixarntz felixarntz added the ai/harness related to the harness layer label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/harness related to the harness layer task-merge-tracking-no-issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants