# Reviewed API execution experiment

Protocol fixed before the measured run. This is a separate fictional ecommerce app;
all identities are synthetic and no payment service is called.

## Question and conditions

Does replacing repeated agent reasoning with an owner-reviewed, deterministic API
operation improve execution? What does Smart365's gateway add beyond an equivalent
customer integration?

- **Individual APIs**: the agent calls six typed write operations, reads the saved
  order, and reports its ID.
- **Direct compiled integration**: one `checkout` tool calls those same six writes
  and independent read using Smart365's downloadable connector dispatch code,
  without the Smart365 gateway.
- **Smart365 network**: the identical `checkout` schema, system instructions and
  compact result use the actual `NetworkAgentClient`, HTTP gateway, durable jobs,
  scopes, owner-enrolled worker and independent verification. There are no model
  calls inside either deterministic executor.

The compound tool's business input is identical in the latter two conditions. Its
benefit over individual APIs must not be attributed exclusively to Smart365: a
customer can build an equivalent API wrapper. The gateway's distinct contribution
is its permissions, review/publication, connection binding, leased dispatch,
idempotent execution receipt, independent verifier and audit trail. It has overhead.

Three matched goals use dependent product, discount, address, delivery, payment,
approval and receipt decisions. Each starts with a fresh shopper account and the
same budget and delegated scopes. Each condition is measured once per goal (nine
trials), counterbalanced with a Latin square. Model: OpenAI `gpt-4.1`, temperature 0,
serial tool calls, at most 18 model turns and 1,400 output tokens per response.
Record resolved model version and actual provider usage including cached input.
This small synthetic test is descriptive, not a universal speed/cost guarantee.

## Recording and review

An authorized Playwright demonstration recorded the six observed POST request
shapes (names/types only), not authentication headers, cookies, input values or
responses. The compiler combines those shapes with explicit owner-authored schemas,
bindings and a separately supplied saved-order GET endpoint. The capture remains a
review draft; it does not discover safe authorization or verification automatically.
The owner explicitly publishes and enrolls through the normal Network Console APIs.

Conceptual reference: Pomerado, MIT, source reviewed at
`1d8a016862b6b1c8e43c770a75514d487efb8bc5`. No Pomerado implementation is included.
Its browser-oriented open-source host needs a supplied transport for HTTP operations.
The SDK under `integration/vendor/sdk-agent` is Smart365's actual customer worker,
vendored from the platform's connector implementation to keep this app separate.

## Measurement

Timers include all outer model calls, tool execution, provider requests, gateway
execution and verification. Session creation, worker enrollment/startup, recording,
compilation and human review are setup costs excluded from each execution timer;
they are required work, not free automatic setup. Independent SQLite validation
checks exact saved fields, totals, budget, claimed ID and exactly one order.

Save every measured trace, prompt, provider usage, error and failed trial. Refuse
output directory collisions. Do not replace a failed trial with a successful rerun.
Retain the earlier negative browser/guide experiment as historical results rather
than describing it as a concurrent browser baseline. Network comparisons use only
the new matched API conditions.

Report total input + output tokens separately from caching. These token counts are
not billed dollars. Host requests exclude setup; gateway worker request counts
include polling over the worker's entire lifetime, including idle setup. Gateway
polling adds HTTP and database work and needs operational tuning/retention.

## Authority and deployment limits

Workers use short-lived scoped host tokens issued through the shopper's own session.
The host still enforces role, budget, prerequisites, approval and duplicate protection.
Worker credentials are never model arguments. Gateway completion checks the current
connection, manifest origin, scope and lease. Uncertain writes are not auto-replayed;
a fresh independent read is required. A customer worker is a trusted runtime, not an
arbitrary-code sandbox, and the customer's API establishes its host account identity.

The measured Node/SQLite host and gateway run locally with real HTTP. Vercel hosts a
static interactive preview and evidence page, not the measured persistent backend.
