Skip to content

Commit 37a8a22

Browse files
committed
Add CUA AgentHarness model switching
1 parent 7df5044 commit 37a8a22

9 files changed

Lines changed: 304 additions & 113 deletions

File tree

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ someone who wants to read the code, contribute, or fork.
4141
- provider payload transforms and protocol quirks (for example, Yutori tool serialization policy)
4242
- canonical CUA tool-definition exports
4343
- `@onkernel/cua-agent` owns browser execution orchestration:
44-
- `CuaAgent` / `CuaHarness` class wiring around `pi-agent-core`
44+
- `CuaAgent` / `CuaAgentHarness` class wiring around `pi-agent-core`
4545
- executing canonical CUA tool calls against Kernel browsers
4646
- typed executor coverage and translator integration
4747

packages/agent/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 0.1.0
44

5-
- Class-first CUA runtime: `CuaAgent` and `CuaHarness` on top of pi-agent-core.
5+
- Class-first CUA runtime: `CuaAgent` and `CuaAgentHarness` on top of pi-agent-core.
6+
- `CuaAgent` and `CuaAgentHarness` refresh CUA runtime defaults when models change.
67
- Provider-neutral browser tool executors for canonical CUA tool names, backed by Kernel browser actions.
78
- Includes examples plus unit and live e2e coverage for common provider/model combinations.

packages/agent/README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ const agent = new CuaAgent({
3333
await agent.prompt("Open news.ycombinator.com and summarize the top story.");
3434
```
3535

36-
## Quick Start (`CuaHarness`)
36+
## Quick Start (`CuaAgentHarness`)
3737

3838
```ts
39-
import { CuaHarness } from "@onkernel/cua-agent";
39+
import { CuaAgentHarness } from "@onkernel/cua-agent";
4040

41-
const harness = new CuaHarness({
41+
const harness = new CuaAgentHarness({
4242
browser,
4343
client,
4444
model: "openai:gpt-5.5",
@@ -54,17 +54,15 @@ lifecycle events, custom streaming, and explicit prompt/continue/queue control.
5454
Reach for the harness shape when you want an app layer around the loop:
5555
session/transcript helpers, resource and prompt entry points, provider/auth
5656
hooks, active tool selection, compaction/tree workflows, and higher-level queue
57-
events. `CuaHarness` is the thin CUA version of that shape today: it installs
58-
CUA defaults, delegates runtime methods to the wrapped `Agent`, and adds
59-
`getTranscript()`.
57+
events. `CuaAgentHarness` extends pi `AgentHarness`, installs CUA defaults, and
58+
refreshes provider-specific runtime state when `setModel()` changes models.
6059

6160
## Core Concepts
6261

6362
### Class-First API
6463

6564
- `CuaAgent extends Agent`
66-
- `CuaHarness` wraps a pi `Agent` with a harness-style constructor and
67-
delegated runtime methods.
65+
- `CuaAgentHarness extends AgentHarness`
6866

6967
Both classes mirror pi constructor shapes and behavior, with minimal additions:
7068
- `browser` (Kernel browser response)
@@ -84,6 +82,17 @@ If tools are omitted, the classes install canonical CUA computer tool executors
8482
using runtime specs from `@onkernel/cua-ai`. If tools are provided, they are
8583
used exactly.
8684

85+
### Model Switching
86+
87+
`CuaAgent` follows pi `Agent` semantics: assign `agent.state.model` to a
88+
concrete model or CUA model ref. CUA-owned tools and the default system prompt
89+
refresh with the new provider runtime.
90+
91+
`CuaAgentHarness` follows pi `AgentHarness` semantics: call
92+
`await harness.setModel(model)`. The harness updates its model through pi's
93+
snapshot machinery and refreshes CUA-owned tools and default prompt state for
94+
the next provider request.
95+
8796
### Tool Composition
8897

8998
Use `createCuaComputerTools()` to compose your own tool list from canonical

packages/agent/examples/harness-openai-smoke.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Kernel from "@onkernel/sdk";
22
import { requireCuaEnvApiKeyForModel, type CuaModelRef } from "@onkernel/cua-ai";
3-
import { CuaHarness } from "../src/index";
3+
import { CuaAgentHarness } from "../src/index";
44
import { SCENARIOS } from "./shared/scenarios";
55

66
const modelRef = (process.env.MODEL_REF as CuaModelRef | undefined) ?? "openai:gpt-5.5";
@@ -13,7 +13,7 @@ async function main(): Promise<void> {
1313
const browser = await client.browsers.create({ stealth: true });
1414

1515
try {
16-
const harness = new CuaHarness({
16+
const harness = new CuaAgentHarness({
1717
browser,
1818
client,
1919
model: modelRef,

packages/agent/examples/harness-provider-matrix.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Kernel from "@onkernel/sdk";
22
import { requireCuaEnvApiKeyForModel, type CuaModelRef } from "@onkernel/cua-ai";
3-
import { CuaHarness } from "../src/index";
3+
import { CuaAgentHarness } from "../src/index";
44
import { SCENARIOS } from "./shared/scenarios";
55

66
const modelRef = (process.env.MODEL_REF as CuaModelRef | undefined) ?? "openai:gpt-5.5";
@@ -15,7 +15,7 @@ async function main(): Promise<void> {
1515
const scenario = SCENARIOS.find((entry) => entry.name === scenarioName) ?? SCENARIOS[0]!;
1616

1717
try {
18-
const harness = new CuaHarness({
18+
const harness = new CuaAgentHarness({
1919
browser,
2020
client,
2121
model: modelRef,

0 commit comments

Comments
 (0)