Skip to content

Add an agent session driver and Gadget durability tests - #270

Closed
AshishKumar4 wants to merge 7 commits into
mainfrom
evals/toolkit
Closed

Add an agent session driver and Gadget durability tests#270
AshishKumar4 wants to merge 7 commits into
mainfrom
evals/toolkit

Conversation

@AshishKumar4

@AshishKumar4 AshishKumar4 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Adds the reusable out-of-process driver for Workshop integration tests and live agent evals.

Everything in this PR is deterministic and runs in pnpm test. It does not call a model.

AgentSession

AgentSession drives the same public Cap'n Web API as the browser. It:

  • opens a new workspace and keeps one chat across turns
  • waits for the production agent lifecycle to settle
  • reads complete canonical history and workpieces
  • connects to generated Gadget RPCs
  • accepts the chat's proposed changes through the current git-backed merge API
  • reports chat token and cost metadata when available
  • disposes every subscription and RPC capability

Local sessions create an isolated password account. A deployed preview can attach an Access application JWT to the WebSocket handshake and call authenticateFromCfAccess().

Shared harness

startHarness() can retain the Worker Loader when an agent eval needs to execute generated Gadgets. Existing deterministic integration tests continue to use the same multi-Worker workerd and gatekeeper setup.

Verification

  • pnpm --filter @gadgets/integration-tests build
  • pnpm --filter @gadgets/integration-tests test:run
  • 27 tests pass

The live eval package that consumes this driver is stacked in #271.

Comment thread packages/integration-tests/fixtures/seeded-gadgets.ts Outdated
@AshishKumar4
AshishKumar4 force-pushed the evals/toolkit branch 2 times, most recently from bf05017 to e10294c Compare August 24, 2026 17:34
AgentSession drives one agent session over the same Cap'n Web API the
browser uses: a fresh account and workspace, one chat across turns,
complete paginated history, and an optional source snapshot.

Two methods support tests that need a known implementation rather than
whatever an agent produced. seedGadget() writes hand-authored source into
the workspace. restartGadgets() restarts every Gadget server by applying an
empty code update, which is what the platform does on every code change.

gadget-durability.test.ts uses both to pin platform behaviour with no model
involved. Storage survives a restart and memory does not, outstanding stubs
become invalid, and the data holds across five restarts and across one that
interrupts a write. It also shows that a check-then-write implementation
oversells under concurrent calls.

startHarness() gains enableGadgetExecution, which keeps the Worker Loader so
Gadget code can run. It defaults to false, so the existing suites are
unchanged.
A handler receives the URL, the method, and the headers, but never the body,
so it cannot stand in for a host a suite has to reach with a real POST.
passThroughHosts exempts such a host before the request is taken apart.
Every other host still throws.
Every .js file in a Gadget becomes a module in its Worker, so workerd parses
client.js at load even though the server never imports it. A test that checks
a Gadget through its RPC therefore already covers the syntax of both files,
and a separate parse step would add nothing.
@AshishKumar4

Copy link
Copy Markdown
Contributor Author

The reduced eval implementation and its shared session driver now belong to one review unit. #271 contains this branch and is being retargeted to main.

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.

2 participants