Skip to content

fix: serve OpenRouter's removal rejection for openai/sora-2 - #520

Merged
jpr5 merged 2 commits into
mainfrom
fix/openrouter-video-sora-removed
Oct 10, 2026
Merged

jpr5 merged 2 commits into
mainfrom
fix/openrouter-video-sora-removed

Conversation

@jpr5

@jpr5 jpr5 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Summary

The daily Drift Tests have reported a critical since 2026-10-06 (first seen in run 37422677099, again in 38030209547 and 38001928761): aimock's OpenRouter video proxy mirrors the sora family, but the live GET /api/v1/videos/models listing no longer has it.

OpenRouter removed openai/sora-2. It did not just deprecate it. Under the deprecation policy, a removed model must not mock success. The mock now serves the rejection the real API returns, and the drift check no longer requires the family.

What OpenRouter returns now (observed live, 2026-10-10)

  • GET /api/v1/videos/models: 30 models. None is openai/sora*. Families: aleph, avatar, flux, gen, grok, hailuo, happyhorse, heygen, kling, seedance, veo, wan.
  • GET /api/v1/models (458 models): no sora id.
  • GET /api/v1/models/openai/sora-2/endpoints: 404 {"error":{"message":"Not Found","code":404}}.
  • POST /api/v1/videos with a valid key and {"model":"openai/sora-2","prompt":"a cat","duration":4}:
HTTP/2 400
content-type: application/json
{"error":{"message":"Model openai/sora-2 does not exist","code":400}}

That is the same rejection OpenRouter gives an unknown id: nonexistent/zzz-1 returns 400 "Model nonexistent/zzz-1 does not exist". No job was created.

Changes

  • src/openrouter-video.ts
    • New private OPENROUTER_VIDEO_SUNSET_MODELS = {"openai/sora-2"}.
    • POST /api/v1/videos with a sunset model returns the observed 400 body (journaled, fixture: null). This happens before fixture matching, chaos and the record proxy, so no fixture can make it succeed and nothing goes upstream.
    • DEFAULT_OPENROUTER_VIDEO_MODELS is now ["bytedance/seedance-2.0"]. A fixture for a sunset model no longer adds it to the synthesized listing.
  • src/__tests__/drift/openrouter-video.drift.ts
    • REQUIRED_VIDEO_FAMILIES is now ["seedance"]. Sora is explicitly excluded from drift, as the policy requires.
    • New live sunset canary: it fails if openai/sora-2 returns to the live listing, because then the mock's 400 would be what had drifted. Mutation check: putting bytedance/seedance-2.0 in the sunset list makes the canary fail.
  • src/__tests__/openrouter-video.test.ts: 4 new sunset tests, written first and seen failing. The listing-synthesis test now uses google/veo-3.1 instead of openai/sora-2.
  • src/__tests__/drift/providers.ts: comment example only.
  • docs/openrouter-video/index.html: new "Removed Models" section. CHANGELOG.md: loud [Unreleased] / Changed entry. This is a normal release, not a major.

Local red-green proof

RED (base bc436346, real OPENROUTER_API_KEY, live API)

npx vitest run --config vitest.config.drift.ts --reporter=verbose src/__tests__/drift/openrouter-video.drift.ts

 × OpenRouter video model-family availability (live) > live /api/v1/videos/models contains the families aimock mirrors
  1. [critical] aimock's OpenRouter video proxy mirrors the "sora" family, but the live /api/v1/videos/models listing no longer contains it — update DEFAULT_OPENROUTER_VIDEO_MODELS in src/openrouter-video.ts
     Path:    videos/models/sora
     Real:    aleph, avatar, flux, gen, grok, hailuo, happyhorse, heygen, kling, seedance, veo, wan
      Tests  1 failed | 3 passed (4)

Mock before the fix (built dist, real HTTP):

[no-fixtures]  listing=["bytedance/seedance-2.0","openai/sora-2"]
[no-fixtures]  POST /api/v1/videos model=openai/sora-2 -> 404 {"error":{"message":"No fixture matched","code":404}}
[sora-fixture] listing=["openai/sora-2"]
[sora-fixture] POST /api/v1/videos model=openai/sora-2 -> 202 {"id":"d90d85fe-…","polling_url":"…","status":"pending"}

GREEN (this branch, same command, same key, live API)

 ✓ OpenRouter video-proxy envelope shapes > submit returns { id, polling_url, status }
 ✓ OpenRouter video-proxy envelope shapes > completed status poll returns { id, status, unsigned_urls, usage }
 ✓ OpenRouter video-proxy envelope shapes > models listing returns { data: [ { id, name, supported_* , ... } ] }
 ✓ OpenRouter video model-family availability (live) > live /api/v1/videos/models contains the families aimock mirrors
 ✓ OpenRouter video model-family availability (live) > live /api/v1/videos/models still omits the models aimock serves as sunset
      Tests  5 passed (5)

Mock after the fix:

[no-fixtures]  listing=["bytedance/seedance-2.0"]
[no-fixtures]  POST /api/v1/videos model=openai/sora-2 -> 400 {"error":{"message":"Model openai/sora-2 does not exist","code":400}}
[sora-fixture] listing=["bytedance/seedance-2.0"]
[sora-fixture] POST /api/v1/videos model=openai/sora-2 -> 400 {"error":{"message":"Model openai/sora-2 does not exist","code":400}}

Public type compatibility

  • DEFAULT_OPENROUTER_VIDEO_MODELS and the new set are module-private. No exported type changed.
  • I diffed dist/*.d.ts and *.d.cts (172 files) against npm pack @copilotkit/aimock@1.45.0 and against a base build. 6 ws-* files differ only in bundler import alias numbering (node_http2 vs node_http3); they are identical after normalizing that. openrouter-video.d.ts is identical apart from the sourceMappingURL line.
  • Consumer proof: a small consumer (LLMock, Fixture, a video fixture for openai/sora-2) passes tsc with strict and skipLibCheck: false against both npm 1.45.0 and this branch's build.

Quality gates (worktree root)

  • pnpm format:check: pass
  • pnpm lint: pass
  • pnpm typecheck: pass
  • pnpm build: pass
  • pnpm test: 377 files, 14073 passed, 3 skipped. The first run hit one timeout in ws-framing.test.ts while builds ran at the same time. That file passed 3 of 3 times on its own, and the full rerun was clean.

Out of scope

openai/sora-2-pro still has an OpenRouter model page, with zero endpoints, and returns 404 "No endpoints found for openai/sora-2-pro.". aimock never mirrored it, so it is not changed here. OpenAI's direct /v1/videos Sora surface is also unchanged.

jpr5 added 2 commits October 10, 2026 15:24
OpenRouter removed openai/sora-2: it is gone from /api/v1/videos/models
and /api/v1/models, and a live submit now returns
400 {"error":{"message":"Model openai/sora-2 does not exist","code":400}}.

Per the deprecation policy, the video submit route returns that 400 for
the model before fixture matching, chaos and the record proxy, and the
models listing no longer advertises it (default set or fixtures).
The live family canary now requires only seedance, and a new sunset
canary fails if openai/sora-2 comes back to the live listing (which
would mean the mock's removal rejection is the thing that drifted).
@pkg-pr-new

pkg-pr-new Bot commented Oct 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@520

commit: 898f670

@jpr5
jpr5 marked this pull request as ready for review October 10, 2026 23:04
@jpr5
jpr5 merged commit 51fe9b8 into main Oct 10, 2026
36 of 38 checks passed
@jpr5
jpr5 deleted the fix/openrouter-video-sora-removed branch October 10, 2026 23:04
jpr5 added a commit that referenced this pull request Oct 11, 2026
#521)

## Problem

`OpenRouter K9 reasoning exhaustion > paid live provider agrees with
actual localhost K9` fails on main with `OpenRouter K9 exceeded 256 KiB`
(`openrouter-chat.drift.ts:224`). It failed in Drift Tests runs
37981755809 and 37994194206, and in #520's drift-live-pr run 38091527077
(attempt 2).

The oversized side is the live provider, not aimock.
`deepseek/deepseek-r1` has one OpenRouter endpoint, `novita/fp8`, and it
often ignores `max_tokens: 16`.

## RED: measurements on the old pin (exact test request)

| Batch | Unbounded | Bounded calls |
|---|---|---|
| 4 calls, 120s / 4 MiB limit | 2 / 4 | 4,567 B, 16 completion tokens,
`length`, usage, `[DONE]` |
| 6 calls, 60s / 300 KB limit | 4 / 6 | same |
| 6 calls with `reasoning.max_tokens: 16` added | 2 / 6 | same |

The unbounded calls were all `provider: "Novita"`, reasoning-only and
about 380 B per chunk. They passed 256 KiB in about 25s and reached 1.22
MB at 120s with no finish reason, usage or `[DONE]`. No other limit
parameter is allowed: the endpoint supports only `reasoning`,
`include_reasoning` and `max_tokens`, and the request sets
`require_parameters: true`.

## Fix

Pin the live K9 leg to `qwen/qwen3-32b` on `deepinfra/fp8`. The request
keeps `max_tokens: 16`, `reasoning`, `stream_options.include_usage`,
`allow_fallbacks: false` and `require_parameters: true`.
`inspectK9Stream` and the K9 contract checks are unchanged. The
localhost fixture is keyed on `K9_REQUEST.model`, so the comparison
stays apples-to-apples with no `src/` change.

The model's endpoints when pinned are `deepinfra/fp8` ($0.28/M out),
`tenstorrent/fp8` and `siliconflow/fp8`. Fallbacks stay off, so no other
endpoint can take the leg over.

## Candidate measurements (exact request, 45s / 256 KiB)

Each call was checked by a port of `inspectK9Stream` with every check it
makes: `model` echo, exact `reasoning_details` (`type:
"reasoning.text"`, `format: "unknown"`, `index: 0`), `role: "assistant"`
with `content: ""` on reasoning deltas, no `reasoning_content` or
`tool_calls`, no reasoning after the `length` terminal, usage after the
terminal and not repeated, and a single `[DONE]`. A call counts only if
all of those pass.

| Model / endpoint | Result |
|---|---|
| **qwen/qwen3-32b deepinfra/fp8** | **40 / 40 passed every check**,
5,285 to 5,360 B, `completion_tokens` 16 on all 40 |
| deepseek/deepseek-r1-0528 deepinfra/fp4 | 20 / 20 bounded, but about
8x the cost |
| qwen/qwen3-14b deepinfra/fp8, qwen/qwen3.5-9b deepinfra/bf16,
z-ai/glm-4.7-flash venice/fp8, nvidia/nemotron-3-nano nebius/fp8 | 2 / 2
OK (screening only) |
| deepseek/deepseek-v3.2-exp siliconflow/fp8 | 0 / 2, unbounded
(rejected) |

## Budget check on the live leg (second commit)

A provider that ignores the budget can still end with `finish_reason:
"length"`. So inspecting the live provider stream now also requires
`usage.completion_tokens <= max_tokens`, through an explicit
`inspectK9Stream(raw, { enforceBudget: true })` at the live call site.

The localhost comparison keeps exactly the checks it had before.
aimock's usage estimate (`src/helpers.ts:1538`, `ceil(chars / 4)`)
ignores `max_tokens` and reports 20 for the live 79-character reasoning.
That is tracked separately, and this PR makes no `src/` change.

**RED (mutation):** a local sensitivity check rewrites
`completion_tokens` to 17 and expects the budget-enforcing path to
throw. Without the assertion:

```
× OpenRouter K9 reasoning exhaustion > local wire preserves reasoning/details and clean length/usage/DONE semantics
  → expected [Function] to throw an error   (openrouter-chat.drift.ts:277)
  Tests  1 failed | 8 skipped (9)
```

With the assertion it passes (1 passed). If the `enforceBudget` branch
is disabled (`if (false && enforceBudget)`), the same test fails again
with `expected [Function] to throw an error`.


The run used `npx vitest run
src/__tests__/drift/openrouter-chat.drift.ts --config
vitest.config.drift.ts -t "OpenRouter K9"` with `OPENROUTER_API_KEY`
set:

```
run1 exit=0
 ✓ OpenRouter K9 reasoning exhaustion > paid live provider agrees with actual localhost K9  3668ms
      Tests  2 passed | 7 skipped (9)
live: status 200 completed True bytes 5435 provider DeepInfra completion_tokens 16
run2 exit=0
 ✓ OpenRouter K9 reasoning exhaustion > paid live provider agrees with actual localhost K9  607ms
      Tests  2 passed | 7 skipped (9)
live: status 200 completed True bytes 5285 provider DeepInfra completion_tokens 16
```

These runs include the budget check. The first commit's two GREEN runs
also passed (5,310 B and 5,285 B).

The whole drift file with the key set: 9 / 9 passed. A local RED run of
the old pin passed once (4,567 B), because the failure is intermittent.
The RED evidence is the measurements above plus the CI failures.

## Gates

`pnpm typecheck`, `pnpm lint`, `pnpm format:check` and `pnpm build` all
pass. `pnpm test` passes: 377 files, 14,073 passed and 3 skipped. Only
the drift test file changes, so there is no public API or `.d.ts`
change.
jpr5 added a commit that referenced this pull request Oct 11, 2026
…ve legs (#522)

## Problem

Three "Gemini Interactions live incomplete contracts" drift tests fail
now and then on main (Scheduled Drift Tests run 38030209547, and PR
#520's drift-live-pr run 38091527077):

- `'K5 object'`: `expected 400 to be 200`
- `'K9 object'`: `expected [...] to have a length of 1 but got 2`
(`steps`)
- `'K9 stream'`: same cause, seen in run 37994194206

## Root cause: upstream model nondeterminism

aimock and the test's request are both fine. I re-sent the test's exact
requests to live `gemini-2.5-flash` on 2026-10-10:

| Request | Matches the capture | Variant |
|---|---|---|
| K5 object | 26/28 | 2/28: HTTP 400 `{"error":{"message":"Model
generated invalid JSON syntax ...","code":"malformed_tool_call"}}` |
| K9 object | 44/47 | 3/47: a trailing `model_output` step after the
thought (1-2 output tokens) |
| K9 stream | 46/47 | 1/47: a `thought_signature` delta, then a
`model_output` step with one text delta (plus one failed local test run)
|

The failing K9 assertion is the native-side check
(`incompleteContract(nativeRaw)`, line 510), not localhost.

I also tried making the K9 trigger reliable by changing the request. No
value fixed it:

| `max_output_tokens` | 8 | 16 | 24 | 28 | 32 (kept) | 48 | 64 | 128 |
|---|---|---|---|---|---|---|---|---|
| Object variant | 4/6 | 6/6 | 4/6 | 6/6 | ~3/47 | 0/6 | 6/6 | 6/6 |
| Stream variant | 6/6 | 6/6 | 4/6 | 6/6 | ~1/47 | 1/6 | 6/6 | 6/6 |

`thinking_level: "low"` was worse (3/6 and 4/6). `"medium"` is rejected
with a 400 by this model.

## Change (one test file only)

- **K5:** the live native leg also accepts HTTP 400 whose body is
exactly `{"error":{"message":<string>,"code":"malformed_tool_call"}}`.
Any other status, code or body shape still fails. Localhost is still
graded strictly against the capture.
- **K9 (object and stream):** the live native leg also accepts exactly
one trailing `model_output` step with one non-empty text part.
  - Object: 1-6 output tokens.
- Stream: one `thought_signature` delta closing step 0, then 1-6 text
deltas in step 1.
- The variant is validated, then removed, and the rest must pass the
**unchanged** strict thought-only contract.
- `max_output_tokens` stays at 32. Captured references, derived
segmentation tests and localhost stay strict.
- Real native captures of all three variants are embedded with their
sha256. New tests check that the variants are accepted, that they are
rejected outside the live native leg, and that mutated shapes are
rejected.

## Mutation check

These tests run without a key. I changed the new contract code one way
at a time to see whether a test catches each change. All 12 changes were
caught (at least 1 test failed for each):

- remove either output-token bound, or either stream text-delta bound
- remove the signature-delta check, the answer `step.start` check, the
object answer shape check, or the non-empty answer text checks
- accept any K5 error code, or any HTTP status
- apply the variant outside the live native leg

Rejected mutant shapes include:
- K9 object: two `model_output` steps, wrong order, wrong step type, an
extra field, empty or doubled content, 0 or 7 output tokens,
`output_text` set, `status: completed`
- K9 stream: missing or wrong-type signature, no answer delta, a second
answer step, 7 deltas, empty text, the answer in the terminal
interaction
- K5: codes `invalid_request` or `MALFORMED_TOOL_CALL`, a missing code,
extra fields, statuses 200/429/500, a non-JSON body

## RED (before, live, `npx vitest run --config vitest.config.drift.ts
src/__tests__/drift/gemini-interactions.drift.ts -t "live incomplete"`)

```
   ✓ ... live incomplete contracts > 'K5 object' matches native and localhost  834ms
   × ... live incomplete contracts > 'K9 stream' matches native and localhost 1617ms
     → expected [ 'interaction.created', …(9) ] to deeply equal [ 'interaction.created', …(7) ]
       (live stream had: step.delta, step.stop, step.start, step.delta, step.stop — a second step)
 ❯ incompleteContract gemini-interactions.drift.ts:430:22
 ❯ compareLocalIncomplete gemini-interactions.drift.ts:510:10   <- native side
      Tests  1 failed | 2 passed | 21 skipped (24)
```

The K5 400 and K9 object variant reproduced in direct live probes (table
above). CI shows the same failures.

## GREEN (after, live, `npx vitest run --config vitest.config.drift.ts
src/__tests__/drift/gemini-interactions.drift.ts`, two consecutive runs)

```
== run 1
   ✓ ... live incomplete contracts > 'K5 object' matches native and localhost  590ms
   ✓ ... live incomplete contracts > 'K9 stream' matches native and localhost  1157ms
   ✓ ... live incomplete contracts > 'K9 object' matches native and localhost  1593ms
      Tests  30 passed (30)
== run 2
   ✓ ... live incomplete contracts > 'K5 object' matches native and localhost  594ms
   ✓ ... live incomplete contracts > 'K9 stream' matches native and localhost  1390ms
   ✓ ... live incomplete contracts > 'K9 object' matches native and localhost  2103ms
      Tests  30 passed (30)
```

At a ~5% rate, the live runs mostly exercise the strict path. The
keyless variant tests exercise the accept path with real captured
variant bodies.

## Gates

`pnpm typecheck`, `pnpm lint`, `pnpm format:check` and `pnpm build` all
pass. `pnpm test`: 377 files, 14073 passed, 3 skipped. No `src/`
changes, so the public API and types are unchanged.

## Review follow-up

I checked the review findings against live evidence before changing
anything:

- **A1 (K9 stream usage stays strict at 0 output tokens): no change.**
13 live K9 stream variants with the trailing `model_output` step all
report `total_output_tokens: 0` in final usage: 11 new probes at
`max_output_tokens: 16`, where the variant shows up 11/12 times, plus
the two earlier captures. A further 20 probes at 32 had no variant.
Unlike the object, the stream reports 0, so the strict check is correct.
- **A2 (K5 stream rejects `thought_signature` deltas): no change.** None
of 20 live K5 stream calls had a thought step or a `thought_signature`
delta. 19 had no steps at all, and 1 returned HTTP 400
`malformed_tool_call`. The signature capture in this PR is a K9 stream.
- **B:** the live-contract comment now names the two accepted upstream
variants.

Re-check after this change: the live drift command for this file passed
30/30 on two more consecutive runs. All gates pass again, and `pnpm
test` is 14073 passed, 3 skipped.

Earlier CI note: `test (22)` failed once on `validate CLI — report-mode
consistency > does not print OK ...` because the random temp dir
`/tmp/aimock-validate-modes-GEgOKg` contains "OK". The same test failed
on main in run 38007611924. The rerun passed.
@jpr5 jpr5 mentioned this pull request Oct 12, 2026
jpr5 added a commit that referenced this pull request Oct 12, 2026
Patch release npm/plugin **1.45.1** from `main` at a23779e (#529
merged). aimock-pytest stays at 0.7.0 (its `pyproject.toml` version is
unchanged); only its default aimock pin moves to 1.45.1.

> **Prepared, not merged.** `publish-release.yml` runs on every push to
`main`. Merging this PR publishes npm `@copilotkit/aimock@1.45.1`, the
`v1.45.1` tag, the `v1` major-tag move, the GitHub Release, the Docker
images and the Slack announcement. Merge only when the release is
authorized.

## What's in 1.45.1

### Changed

- **OpenRouter Video: `openai/sora-2` returns the real removal
rejection** ([#520](#520)).
OpenRouter removed the model; a live submit returns `400
{"error":{"message":"Model openai/sora-2 does not exist","code":400}}`.
`POST /api/v1/videos` with `model: "openai/sora-2"` now returns that 400
even when a fixture matches, and never reaches a record-mode upstream.
The default `GET /api/v1/videos/models` listing no longer includes
`openai/sora-2`, and a fixture for it no longer adds it. Move fixtures
to a model OpenRouter still serves (for example
`bytedance/seedance-2.0`). The daily drift check now confirms the model
stays absent.

### Fixed

- **MCP `tools/list` gives every registered tool an `inputSchema`**
([#529](#529)). A tool
registered with `addTool()` without an `inputSchema`, or only via
`onToolCall()`, was listed with no `inputSchema`, and the official MCP
SDK client rejected the whole `tools/list` response. These tools are now
listed with `inputSchema: { "type": "object" }`, as fake-only tools
already were. Tools registered with an `inputSchema` are unchanged.
- **MCP `tools/list` adds `"type": "object"` to a typeless registered
schema** ([#529](#529)). A
schema such as `{}` or `{ "properties": { ... } }` was listed as is, and
the SDK client rejected it (`inputSchema.type: expected "object"`). It
is now listed with `"type": "object"` added and its other keys kept. A
schema with an explicit `type` is unchanged.

Everything else merged since v1.45.0 is test-only.

## Versions

| Surface | Before | After |
|---|---|---|
| `package.json` `version` | 1.45.0 | 1.45.1 |
| `.claude-plugin/plugin.json` `version` | 1.45.0 | 1.45.1 |
| `.claude-plugin/marketplace.json` `plugins[0].source.version` |
^1.45.0 | ^1.45.1 |
| `charts/aimock/Chart.yaml` `appVersion` (chart `version` stays 0.1.0)
| 1.45.0 | 1.45.1 |
| `docs/index.html` CLI banner | aimock v1.45.0 | aimock v1.45.1 |
| `packages/aimock-pytest/src/aimock_pytest/_version.py`
`AIMOCK_VERSION` | 1.45.0 | 1.45.1 |
| `packages/aimock-pytest/README.md` `--aimock-version` default | 1.45.0
| 1.45.1 |

Left at 1.45.0 on purpose: CHANGELOG history, and "requires 1.45.0 or
later" minimum-version notes in `README.md`, `docs/*`,
`packages/aimock-pytest/README.md` and `skills/write-fixtures/SKILL.md`,
plus the illustrative `aimockVersion` in the `docs/mcp-mock`
recorded-file example. `pnpm-lock.yaml` does not carry the root version.

`CHANGELOG.md`: `[Unreleased]` became `[1.45.1] - 2026-10-11` with an
empty `[Unreleased]` kept above it, as in prior releases.

## Local gates

- `pnpm install --frozen-lockfile`: pass
- `pnpm format:check`: pass
- `pnpm lint`: pass
- `pnpm typecheck`: pass
- `pnpm build`: pass
- `vitest run` on `npm-publish-verify-workflow`,
`unreleased-check-workflow`, `drift-scripts`, `openrouter-video-record`:
4 files, 165 tests pass
q-qp-p pushed a commit to q-qp-p/copilotkit-aimock that referenced this pull request Oct 19, 2026
## [1.45.1] - 2026-10-11

### Changed

- OpenRouter Video: `openai/sora-2` now returns OpenRouter's 400 removal error, not a job (CopilotKit#520)

### Fixed

- MCP `tools/list`: a tool registered without `inputSchema` now lists `{"type":"object"}` (CopilotKit#529)
- MCP `tools/list`: a registered `inputSchema` with no `type` now gets `"type": "object"` (CopilotKit#529)
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.

1 participant