Skip to content

Commit 27cfee2

Browse files
committed
Make agent tool configuration explicit
1 parent 1782b43 commit 27cfee2

100 files changed

Lines changed: 6482 additions & 8283 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,18 @@ cua "go to news.ycombinator.com and tell me the top 3 story titles"
1212

1313
## Why this exists
1414

15-
Frontier models expose computer use through different tool protocols:
16-
17-
- **OpenAI gpt-5.5**: a built-in `computer` tool that emits actions like
18-
`{type:"click", x, y}`, `{type:"scroll", x, y, scroll_x, scroll_y}`,
19-
`{type:"keypress", keys:[...]}`, …
20-
- **Anthropic claude-opus-5**: a built-in `computer_20251124` tool that
21-
emits `{action:"left_click", coordinate:[x, y]}`,
22-
`{action:"scroll", scroll_direction, scroll_amount}`, …
23-
- **Google gemini-2.5-pro / gemini-3.x**: a set of predefined
24-
computer-use functions (`click_at`, `type_text_at`, `scroll_at`,
25-
`navigate`, `go_back`, …) with 0-1000 normalized coordinates.
26-
- **Meta Muse Spark 1.1**: OpenAI-compatible Responses API function calls
27-
paired with screenshot inputs and 0-1000 normalized coordinates.
28-
- **xAI Grok 4.5**: OpenAI-compatible Responses API function calls with
29-
screenshot inputs, reasoning controls, and 0-1000 normalized coordinates.
30-
- **Yutori Navigator n1 / n1.5**: OpenAI-compatible `chat.completions`
31-
responses with built-in browser action `tool_calls` like `left_click`,
32-
`goto_url`, `type`, and `scroll` in 0-1000 normalized coordinates.
15+
Frontier models expose computer use through different protocols: native
16+
computer/browser declarations, predefined browser action sets, ordinary
17+
function tools, different coordinate systems, and different screenshot/result
18+
contracts. `@onkernel/cua-ai` represents those differences as an explicit,
19+
identity-keyed tool catalog. Callers choose the exact tools; provider transforms
20+
compose only the declarations and request fields required by those identities.
3321

3422
All of them expect you to:
3523

3624
1. Run a real browser somewhere (locally is annoying, on a server is hard).
3725
2. Translate every action into an actual SDK call against that browser.
38-
3. Capture a fresh screenshot after each action and feed it back to the model so it can verify what happened and plan the next step.
26+
3. Return policy-correct grounding: viewport images for browser writes, OS images for computer writes, requested data for reads, and no fresh image on failures.
3927
4. Keep doing this in a loop until the task is done.
4028

4129
`cua` does all of this for you. The repo is structured as several focused npm packages so the per-provider plumbing is also reusable outside of this binary (e.g. by agents of your own spun up via [`kernel/cli`](https://github.com/kernel/cli) templates).
@@ -77,8 +65,8 @@ flowchart LR
7765

7866
| Package | What it ships |
7967
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
80-
| [`@onkernel/cua-ai`](packages/ai) | Computer-use model catalog (`getCuaModel`/`listCuaModels`), canonical CUA tool schemas, and provider adapters/runtime specs built on pi-ai. On npm. |
81-
| [`@onkernel/cua-agent`](packages/agent) | `CuaAgent`/`CuaAgentHarness` classes that execute cua-ai tool calls against a Kernel browser, screenshot loop included. On npm. |
68+
| [`@onkernel/cua-ai`](packages/ai) | Model catalog, explicit identity-keyed CUA tool factories/toolsets, compatibility checks, and composable provider transforms. On npm. |
69+
| [`@onkernel/cua-agent`](packages/agent) | `CuaAgent`/`CuaAgentHarness` composition wrappers with dynamic `setTools()` and shared Kernel-browser execution resources. On npm. |
8270
| [`@onkernel/cua-cli`](packages/cli) | The `cua` binary: argv parsing, sessions, skills, JSONL output, pi-tui front-end. |
8371

8472
---
@@ -134,7 +122,7 @@ cua -p --model moonshotai:kimi-k3 "Same prompt"
134122
# Yutori Navigator
135123
cua -p --model n1.5-latest "Same prompt"
136124

137-
# interactive TUI (default mode)
125+
# interactive TUI (default invocation)
138126
cua
139127
cua "summarize https://news.ycombinator.com"
140128

@@ -156,23 +144,21 @@ cua -p -o jsonl "open example.com and tell me the heading"
156144

157145
## How it works
158146

159-
1. **Model layer**`@onkernel/cua-ai` owns the curated computer-use
160-
model catalog (`getCuaModel`/`listCuaModels`), the canonical CUA
161-
tool-call schemas, and per-provider adapters on top of `pi-ai` so
162-
every model emits the same `CuaAction` vocabulary.
163-
2. **Execution layer**`@onkernel/cua-agent` wraps `pi-agent-core`'s
164-
`Agent`/`AgentHarness`. `CuaAgentHarness` runs the
165-
prompt/screenshot/tool loop against a Kernel browser: it dispatches
166-
canonical CUA tool calls into Kernel SDK `browsers.computer.*` calls
167-
and captures a fresh screenshot back to the model on every turn.
147+
1. **Model layer**`@onkernel/cua-ai` owns the curated model catalog,
148+
stable tool identities, explicit tool factories/toolsets, compatibility
149+
checks, and provider declarations/headers/payload transforms.
150+
2. **Execution layer**`@onkernel/cua-agent` composes around
151+
`pi-agent-core`'s `Agent`/`AgentHarness`. It materializes the caller's exact
152+
catalog over one shared resource pool and executes canonical actions through
153+
Kernel's computer API or a raw-CDP browser executor.
168154
3. **CLI**`@onkernel/cua-cli` assembles a `CuaAgentHarness` from
169155
command-line flags, env-var-based API keys, a `JsonlSessionRepo` for
170156
transcripts, and pi skills; renders the result either as plain text
171157
(`--print`), JSONL events (`-o jsonl`), or an interactive pi-tui
172158
front-end.
173159
4. **Browser** — a fresh Kernel cloud browser session per run (or per
174-
resume) with optional named profile load/save. Every screenshot the
175-
model sees is a real PNG of a real browser tab.
160+
resume) with optional named profile load/save. Grounding images come from
161+
the live browser or VM using the selected tool's explicit result policy.
176162

177163
See [`docs/architecture.md`](docs/architecture.md) for the full
178164
end-to-end flow.
@@ -241,7 +227,7 @@ cua session list # tab-formatted: NAME, KERNEL_ID, AGE, LIVE_URL
241227
cua session show login # full JSON: kernel_session_id, live_url, transcript_path, ...
242228
```
243229

244-
`-s <name>` works for ALL modes (action subcommands, `--print`, the
230+
`-s <name>` works for all invocation styles (action subcommands, `--print`, the
245231
interactive TUI). Liveness is checked before each attach: if the Kernel
246232
browser timed out, the call fails with a clear "session no longer
247233
alive" error suggesting `cua session stop <name> && cua session start

docs/agent-tool-configuration-spec.md

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Agent Tool Configuration
22

3-
**Status:** Draft for later review
3+
**Status:** Implemented
4+
45
**Scope:** `@onkernel/cua-agent` and the tool-building surface in `@onkernel/cua-ai`
56
**Compatibility:** Not a goal; these packages are alpha and may make breaking API changes.
67

@@ -17,7 +18,7 @@ The array may contain:
1718

1819
Provider-recommended tools are intentionally distinct from CUA-authored tools. The former reproduce the basic tools or schemas a model provider recommends in its computer-use examples; the latter are additional capabilities designed and maintained by CUA. A caller should be able to combine either category with custom application tools while seeing exactly what the model receives.
1920

20-
The current `extraTools`, `mode`, `nativeTool`, and `playwright` constructor options should be removed. `activeToolNames`, `setActiveTools()`, `setMode()`, `getMode()`, `computer_use_extra`, and CUA-generated default system prompts should also be removed. No global or derived mode should replace them.
21+
The former `extraTools`, `mode`, `nativeTool`, and `playwright` constructor options are removed. `activeToolNames`, `setActiveTools()`, `setMode()`, `getMode()`, `computer_use_extra`, and CUA-generated default system prompts are also removed. No global or derived mode replaces them.
2122

2223
Each CUA tool specification must contain enough information to build, expose, execute, and describe that tool independently. Convenience toolsets may return arrays of tool specifications, but they must not establish hidden runtime state or add undeclared tools.
2324

@@ -79,7 +80,7 @@ This terminology must also be used consistently in the architecture document, pa
7980
- Silently replacing incompatible tools when the model changes
8081
- Preserving CUA's current default system prompts
8182

82-
## Proposed public namespace
83+
## Public namespace
8384

8485
Tool factories and toolsets should be exported through one discoverable namespace rather than as a collection of global functions.
8586

@@ -118,7 +119,7 @@ The distinction is deliberate:
118119

119120
The exact property names may be refined, but the final exports must remain namespaced, autocomplete-friendly, and free of a large flat list of package-level tool factory functions.
120121

121-
## Proposed constructor API
122+
## Constructor API
122123

123124
Both constructors accept one required top-level `tools` array:
124125

@@ -331,7 +332,7 @@ A tool specification has a stable identity and a preferred model-facing name. Th
331332

332333
Composition sees the complete requested list and must detect name collisions before the first request. It must never silently shadow a tool.
333334

334-
The naming policy is a design blocker that must be resolved before implementation. Candidate behavior is:
335+
The implemented naming policy is:
335336

336337
1. Keep preferred provider-recommended names when unique.
337338
2. Reject collisions by default with an error naming both tool identities.
@@ -341,7 +342,7 @@ The naming policy is a design blocker that must be resolved before implementatio
341342

342343
A toolset factory should not need hidden global state. The central composer sees all expanded tool specs and applies the collision policy. A toolset may expose explicit naming or namespace options, but automatic context-sensitive aliasing must not make the resulting catalog unpredictable.
343344

344-
This policy must be prototyped with provider-recommended computer tools plus CUA browser tools before implementation begins.
345+
Catalog tests cover provider-recommended computer tools composed with CUA browser and caller tools.
345346

346347
## Tools and actions
347348

@@ -365,7 +366,7 @@ Examples:
365366

366367
An operation selected through a tool's arguments.
367368

368-
Current or proposed action-bearing tools include:
369+
Current action-bearing tools include:
369370

370371
- provider-native computer and browser tools, which use an `action` discriminator
371372
- `computer_batch`, which accepts an ordered `actions` array
@@ -392,15 +393,15 @@ A CUA or provider-recommended toolset may choose and document a default batch co
392393

393394
### Browser batch
394395

395-
CUA should offer a browser-plane equivalent that does not dispatch OS computer-use input:
396+
CUA offers a browser-plane equivalent that does not dispatch OS computer-use input:
396397

397398
```ts
398399
cua.tools.browser.batch({
399400
actions: ["snapshot", "click", "fill", "wait_for", "text"],
400401
})
401402
```
402403

403-
The browser batch would execute browser/CDP operations and return their ordered read results. Its action schema, ref lifetime behavior, failure short-circuiting, and result grounding must be specified explicitly.
404+
The browser batch executes browser/CDP operations sequentially over one shared ref table and returns ordered read results. It short-circuits on the first failed or unsatisfied boundary, reports the failed index and skipped count, and follows the browser result-grounding policy.
404405

405406
### Browser batch versus browser act
406407

@@ -409,7 +410,7 @@ The browser batch would execute browser/CDP operations and return their ordered
409410
- `browser_batch` is a mechanical ordered container for explicitly selected browser actions and read results.
410411
- `browser_act` is a dependent plan with per-step and final semantic expectations, causal outcomes, deadlines, stop reasons, and stable successor feedback.
411412

412-
The overlap still needs a design review before implementation. In particular, the design must decide whether ref-producing reads can feed later actions inside one batch and whether a simpler batch should instead be a restricted form of the action-plan tool.
413+
The implemented batch is intentionally not a restricted action-plan tool. Ref-producing reads update the shared ref table before later actions, but the input has no interpolation, saved-value, branch, or workflow syntax. `browser_act` remains the semantic planning surface.
413414

414415
### Native action restrictions
415416

@@ -522,11 +523,11 @@ A provider capability description may include:
522523

523524
Coordinate uncertainty in one computer tool must not disable coordinate-free browser tools such as snapshots, refs, semantic waits, or action plans.
524525

525-
Tzafon and Yutori require adapter changes before arbitrary composition is safe because their current payload hooks replace or suppress tools by name. That limitation should be reported against the affected requested tools, not represented as a blanket rejection of browser or mixed configurations.
526+
Tzafon and Yutori adapters compose by selected identity: Tzafon replaces only its native computer placeholder, while Yutori removes only selected native placeholders and preserves unrelated function tools.
526527

527528
## Removal of `computer_use_extra`
528529

529-
`computer_use_extra` should be deleted entirely: definition, executor, implicit installation, exports, tests, and documentation.
530+
`computer_use_extra` is deleted entirely: definition, executor, implicit installation, exports, tests, and documentation.
530531

531532
No replacement navigation helper is added automatically or under a new hidden name. A caller who needs navigation chooses an explicit capability, such as:
532533

@@ -564,7 +565,7 @@ CUA must not silently drop tools, substitute a different toolset, append fallbac
564565

565566
## Removal of current API
566567

567-
The following constructor options should be removed rather than deprecated:
568+
The following constructor options are removed rather than deprecated:
568569

569570
```ts
570571
extraTools
@@ -574,15 +575,15 @@ playwright
574575
activeToolNames
575576
```
576577

577-
The following methods should be removed from the CUA-facing API:
578+
The following methods are removed from the CUA-facing API:
578579

579580
```ts
580581
setMode()
581582
getMode()
582583
setActiveTools()
583584
```
584585

585-
`computer_use_extra` and CUA-generated default system prompts should be removed with them.
586+
`computer_use_extra` and CUA-generated default system prompts are removed with them.
586587

587588
Their replacements are direct tool-list entries:
588589

@@ -598,7 +599,7 @@ Their replacements are direct tool-list entries:
598599

599600
## Documentation requirements
600601

601-
The future implementation must update:
602+
The implementation updates:
602603

603604
- `docs/architecture.md` with the tool-spec composition and provider-adapter ownership boundaries
604605
- package READMEs with exact constructor examples and no legacy mode terminology
@@ -607,19 +608,15 @@ The future implementation must update:
607608

608609
Provider-recommended toolsets must link to or name the provider guidance they mirror. CUA-authored additions must be described as CUA capabilities rather than provider defaults.
609610

610-
## Design blockers before implementation
611-
612-
No implementation should begin until these questions have concrete prototypes or decisions:
613-
614-
1. **Name composition:** reject versus explicitly alias collisions, especially when provider-native names are fixed.
615-
2. **Payload transforms:** compose native and function tools without classifying them by ambiguous model-facing names.
616-
3. **Grounding ownership:** define post-action browser viewport versus OS display capture per tool, including mixed tool lists.
617-
4. **Batch overlap:** settle the relationship among `computer_batch`, `browser_batch`, and `browser_act`, including intra-batch ref flow.
618-
5. **Dynamic loading:** map `setTools()` onto pi's additive deferred-loading protocol while preserving CUA executors and session history.
619-
6. **Shared resources:** share translators, CDP state, and refs without deriving a mode or allowing one tool to mutate another's public contract.
620-
7. **Provider-recommended exports:** decide exactly which official or example tool shapes each provider namespace promises to mirror and how those promises are tested.
611+
## Implemented design resolutions
621612

622-
These are architecture questions, not implementation details. The spec should be revisited after focused spikes for naming, Tzafon/Yutori payload composition, mixed grounding, and cache-preserving dynamic loading.
613+
1. **Name composition:** exact and provider-normalized collisions reject; caller aliases/namespaces are explicit; native names are fixed.
614+
2. **Payload transforms:** transforms consume stable identities, declare static write claims, and compose in a fixed phase order.
615+
3. **Grounding ownership:** each tool carries browser, computer, request-grounded, read, or failure behavior as data.
616+
4. **Batch overlap:** batches are mechanical; `browser_act` remains semantic; browser batches share ref state without a workflow DSL.
617+
5. **Dynamic loading:** `setTools()` uses pi 0.80.10 additive markers only for final, cache-preserving in-tool additions; other changes are eager.
618+
6. **Shared resources:** one resource pool survives tool/model changes and owns the translator and lazy CDP executor.
619+
7. **Provider-recommended exports:** namespaced Anthropic, Google, Meta, xAI, Moonshot, Tzafon, and Yutori surfaces are tested against their declared contracts.
623620

624621
## Decisions recorded
625622

@@ -632,7 +629,7 @@ These are architecture questions, not implementation details. The spec should be
632629
- `browser_act` remains outside `cua.toolsets.browser()` until it has broader production evidence.
633630
- Naming, payload-transform composition, grounding, and batch overlap must be resolved before code is written.
634631

635-
## Acceptance criteria for a future implementation
632+
## Acceptance criteria
636633

637634
- Both constructors have one required tool-selection source of truth and accept `tools: []`.
638635
- The current tool-related constructor options, active-tool option, and mode methods are removed.

0 commit comments

Comments
 (0)