pnpm exec tsx examples/22-mycel-pass-through/run.ts --smoke # four checks, about a second
pnpm exec tsx examples/22-mycel-pass-through/run.ts --step # present it: press Enter before each act
pnpm exec tsx examples/22-mycel-pass-through/run.ts --json # machine-readable; failures exit 1
No API keys, network services or paid calls. It starts the real Mycel Exchange and a simulated supplier on loopback ports, with an in-memory store, a disposable Application credential and fake credit. The answers are deterministic: this tests the gateway, not a model.
The catalogue advertises only chat. The request carries a JSON schema for routing a refund ticket plus an unknown provider extension. A short SHA-256 fingerprint makes the unchanged request visible; the checks compare the full parsed payload.
| Check | Change | HTTP | New supplier calls | What it shows |
|---|---|---|---|---|
upstream-accepts | Supplier accepts the schema | 200 | 1 | A missing catalogue flag doesn't block the parameter; the typed answer arrives and one debit is recorded |
upstream-rejects | Flip only the supplier | 400 | 1 | Same request, same catalogue, different supplier answer; its status and error body come back |
explicit-constraint-enforced | Caller sends X-Exchange-Require-Capability | 503 | 0 | A routing constraint the caller asks for is still enforced |
no-auth-bypass | Invalid Application credential | 401 | 0 | Pass-through doesn't bypass authentication; the catalogue never changed |
The last two are controls: they show that "forward everything" didn't turn off the gates that should stay.
Presenter prompt before act 2: "Same model, same catalogue, same envelope. Who should decide whether this works?" Before act 3: "What if I explicitly ask the router to restrict my options?"
Break it
In packages/mycel/src/buyer/handler.ts, add structured-output to the required capabilities whenever the body has response_format (the old payload-derived gate). upstream-accepts and upstream-rejects fail, and the smoke exits 1.
The supplier's rejection comes back in Mycel's upstream_error envelope; it isn't a byte-for-byte copy of the supplier's HTTP error. The real-provider counterpart is the three-case Mycel smoke in the Jev pilot report.
Split out of Lab 04, which now tests metering only.
Prompt
Build a self-contained script that boots @umwelten/mycel's Exchange on localhost with an in-memory store and one simulated supplier whose Offer advertises only `chat`. Send a chat completion with a strict `response_format` JSON schema and an unknown provider extension field. Check four things, one PASS/FAIL line each, exit 1 on any failure: (1) with the supplier accepting, the request reaches it byte-for-byte unchanged, returns 200 and records one debit; (2) flipping only the supplier to reject `response_format` returns its 400 in Mycel's `upstream_error` envelope, with the same request forwarded; (3) `X-Exchange-Require-Capability: structured-output` returns 503 `no_eligible_offer` without calling the supplier; (4) an invalid credential returns 401 without calling the supplier, and the catalogue is unchanged throughout. Add `--step` to present it act by act and `--json` for machine-readable output.
--live opt-in
What we learned
The answer
The Exchange forwards what it doesn't understand. A strict JSON schema and an unknown provider extension reach the supplier unchanged for an Offer that advertises only chat. Flipping the supplier, and nothing else, turns a 200 into the supplier's own 400. The catalogue is not a prediction of what works; the supplier is the authority. The gates that should stay still hold: an explicit X-Exchange-Require-Capability gets 503 before any supplier call, and a bad credential gets 401.
What going through it found
- It was hiding inside Lab 04. It lived in
04-mycel-exchange/pass-through.tsand, for a while, was that lab's smoke, so Lab 04's metering claim went unchecked. It's now its own lab, and Lab 04 checks metering only. - One assert stopped the whole run. The script used
node:assertand printed a single PASS at the end, so the first failure hid every later act. Each act is now its own check with a PASS/FAIL line, and the run exits 1 when any fails. - The break test is real. Putting back the payload-derived gate (
response_format⇒structured-output) failsupstream-accepts(503 instead of 200) andupstream-rejects(503 instead of the supplier's 400), and the smoke exits 1.
Gotchas
- A supplier rejection isn't a byte-for-byte pass-through. The buyer gets Mycel's
upstream_errorenvelope withupstreamStatusand the supplier's body as a string inside it. GET /v1/modelscapabilities are routing hints only. A buyer who wants a hard gate has to ask for it withX-Exchange-Require-Capability; selecting by catalogue flags (Lab 02) is a choice, not a guarantee the request will be refused elsewhere.
Not tested
- Real suppliers. Which upstreams accept
response_format, tools or provider extensions is their answer, and this lab only simulates one. - Streaming requests.
Smoke run
PASS upstream-accepts: HTTP 200 {"team":"billing","ticket":"DEMO-42"}; supplier got envelope 89d792af42ab unchanged; one debit
PASS upstream-rejects: HTTP 400 upstream_error/unsupported_parameter; supplier got the same envelope 89d792af42ab
PASS explicit-constraint-enforced: HTTP 503 no_eligible_offer; 0 new supplier calls
PASS no-auth-bypass: HTTP 401; 0 new supplier calls; catalog unchanged across all four acts
4/4 passed