Skip to content

fix(ai): native video handoff to chat-completions providers + preflight video cost - #170920

Merged
steipete merged 22 commits into
openclaw:mainfrom
evomach:pr/native-video-handoff
Oct 16, 2026
Merged

steipete merged 22 commits into
openclaw:mainfrom
evomach:pr/native-video-handoff

Conversation

@evomach

@evomach evomach commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes missing video attachments and false context-overflow errors when an explicitly video-capable Chat Completions model receives a local video.

User Impact

Current, retained, and queued video turns keep their attachment on the original user message, including when a runtime-context row follows it. Video bytes no longer count as millions of prompt-text characters. Canonical runtime models remain text/image-only; the existing authored input: ["text", "image", "video"] configuration enables video only at the compatible provider boundary.

Remote video URLs remain unsupported by this native local-media path, and unsupported models retain an explicit omission outcome. The bounded video estimate is a preflight heuristic, not an exact count of backend frame tokens. No new configuration or migration is required.

Why This Change Was Made

Keep one authoritative media-fact owner through in-memory message projections, then lazily materialize provider media once per physical stream call. Enumerable symbols survive those copies without entering transcript JSON; guarded persistence owns normalization. The selected transport carries the existing provider handoff, and Chat Completions consumes it with a correctly typed provider-only capability projection.

This removes current-turn reinjection, debug tags/probe warnings, silent-skip catches, redundant hydration writes, and cast-based canonical modality widening. It preserves the separation introduced by #121887. The base64 estimate now assigns video parts a fixed 96,000-character cost.

This continues @evomach's original work and preserves all contributor commits. Main was merged, without rebasing or force-pushing. Credit also belongs to evomach's earlier Windows/llama.cpp observations; those observations do not establish behavior on this repaired head.

Production: +220/-182 (net +38); tests: +431/-40 (net +391). Nearby cleanup removes most added production cost; the remaining growth carries the typed provider capability and handoff. Documentation adds one line; configuration adds the package subpath alias and shrinks one assertion allowance from five to three. The maintained PR-wrapper inventory also gains the provider-types runtime module.

Evidence

Exact comparison base: 2afa400a0de8320ad915249b8e617b6a72654dc8. Both runs use an isolated macOS Gateway launched by pnpm openclaw --profile native-video-proof gateway run --port 19731 --bind loopback --auth none, then protocol-v4 sessions.create → chat.send → agent.wait/chat.history.

The baseline source tree matched that main commit: current, retained, and queued requests completed but sent zero video parts (40.1s, 6.5s, 2.0s). The synthetic MP4 is 1,415,341 bytes, SHA-256 883d6c1580b30db119857b148982cd55aeadc27c0e97259c9c3f432b81684464. On the repaired head, current video passed in 9.9s with one native video_url.url part; retained history passed in 1.5s with one part in each request; queued input passed in 1.7s with counts [0, 1] and verified final completion. Every video matched the exact bytes/digest and remained on its original user message, with no media on the following runtime-context row and no duplicate attachment. User text stayed bounded and all requests retained maxTokens: 1024. Unsupported video produced the explicit omission marker (1.0s). The baseline Gateway used Node; the repaired CLI selected Bun. Timings are observations, not a performance comparison.

Real local controls use already-loaded LM Studio google/gemma-4-e4b through that same Gateway/provider path. Before repair, the image control correctly described an unseen red background with a centered blue square (20.1s), and the text control returned its exact requested marker (11.4s). After repair, the image control answered “The image displays a red background with a solid blue square centered in the middle.” (9.0s), and text returned LOCAL_MODEL_CONTROL_OK (3.9s). The image had a neutral outbound filename and no answer hints.

Regression proof: the real normalization/conversion/materialization test fails on main when current-turn facts disappear; restoring only the old estimator makes the managed request with 1.05 MB of base64 video data fail before fetch (93.92s). The repaired provider suites pass 81 tests across seven files (58.45s). The nine core files have 104 passing cases across the initial run and one corrected-file rerun (initial wall 1443.96s; rerun 710.55s, test body 459ms). The initial run exposed a test assertion that expected normalized queued plain text as content blocks; it was corrected to the existing string contract, retaining all media-ownership assertions. The full build passed in 1608.41s with repository-pinned pnpm 12.10.1 and Node 26.12.0. An earlier build was interrupted by a concurrent host Node/library upgrade; the complete rerun passed without skipping phases. The packed-package external-install/export check passed (one test; 127.25s Vitest, 93.39s test body, 1376.33s including runtime preparation). Independent committed-branch Codex autoreview on afd700cd0d1e157012b8e53306053dd6e18fd7c9 is scoped-clean through P2, with no accepted/actionable findings (573.83s).

Scoped validation passed: core types 61.94s; three test type graphs 71.22s; lint 169.53s; format 1.39s; assertion ratchet 38.78s; line-cap, timeout-race, mock-export, config-docs, and plugin-inventory ratchets. Max-lines has an inherited suppression failure in ui/src/pages/chat/components/chat-message.test.tsx, reproduced against the exact base (19.23s); no allowance was expanded.

CI follow-up: the first run exposed a shared test fixture that cast an incomplete model without its required ID, plus a missing runtime import in the extracted PR-wrapper inventory. The follow-up uses the existing typed model fixture and adds exactly that inventory path. MCP/orphan integration tests pass six cases (774.28s including worker preparation), and both wrapper inventory/extraction tests pass (109.74s). The fresh agents-other test-type graph passes (30.46s); an incremental-only diagnostic is recorded separately. Production runtime code is unchanged from the completed build and Gateway proof at 24cf4ed3656d9f9adb45f3ec49f4c7fc4b5a7577. The local catalog-abort suite initially passed nine of ten cases (558.30s), with a missing direct-spawn outcome; a filtered replay failed similarly (339.97s). A temporary terminal-state diagnostic then passed with terminal ok and the original outcome assertions (229.28s wall, 6.802s case). The diagnostic was removed and the checkout verified clean. This passing replay does not establish the prior failure’s cause. All ten catalog cases pass in exact-head CI.

Exact-head CI run 38876932270 tests main base ff13ebe1d6dd5d66befc1449ba71b1234df757cd and completed with 91 passed, 23 skipped, and four failed jobs (the three classified failures below plus openclaw/ci-gate). The aggregate gate is red; a maintainer inherited-failure/tooling exception is needed before landing. The build, baseline ratchets, production/test types, native-video catalog, MCP, wrapper inventory, heartbeat, and Gateway cleanup checks pass. Two test failures are inherited from that exact base: the fake-Bun fixture lacks the revision response required by #173807 (1.23s owner-boundary reproduction; exact owner/fixture blobs unchanged at the final base), and #173972 moved the stale-writer check inside compaction’s existing result-catching block while its test still expects rejection. Executing both exact compaction owners reproduces rejection before that main change and the precise CI failure result afterward (0.49s), without entering the context engine. These are narrow owner-boundary reproductions, not full base-suite runs.

A separate lint job passes its core stripe with zero errors (100.75s), then times out after 300 seconds preparing plugin SDK declarations for the extension stripe. The full build passes independently; this timeout remains a tooling limitation, and no extension-lint success is claimed. Earlier heartbeat and Gateway-cleanup failures did not reproduce locally and now pass in exact-head CI; their earlier causes remain unproven. No CI rerun was requested.

Limitations: video proof captures the exact Gateway-to-provider payload with a deterministic backend, while image/chat controls use a real local model. Native-video perception on this head, Windows/Linux, Telegram, and a stable-version upgrade are not claimed. No installed local backend was established as video-capable.

ClawSweeper: no review of afd700cd0d1e157012b8e53306053dd6e18fd7c9 arrived during the 15-minute polling window after the final push. Its latest comment still reviews b41c66185f94e9febae6fc2a56ddf2a35860839c; both prior code findings are addressed above. The independent final-head review is clean, but no current-head ClawSweeper verdict is claimed.

Landing gate update

The server-side main merge produced reviewed head 8cdb89b344f45a171be1fa81779d6a7ccdb0c31b without changing the repaired implementation. Exact-head CI run 38879350930, attempt 1 completed against main 2a48809c5ce30ea4dc5c715fb599d8d21d92fb75, using tested merge 77a4494afb6cbc60e7dc2aa6b09ac2e1c50812ec.

The only failed root jobs are checks-node-changed-compact-large-1 (the inherited compaction rejection assertion from #173972) and checks-node-compact-small-16 (six inherited fake-Bun fixture cases from #173807). Their failure signatures match the independently reproduced baseline defects. All twelve relevant test and owner files are byte-identical between this exact CI base, the previously reproduced baseline, and this PR head. The CI comparison table reports unknown/new because its scheduled-main job scopes differ; independent exact-source attribution establishes these inherited failures. The aggregate CI gate remains failed. Landing uses the explicitly authorized native pre-existing-failure exception; no CI success is claimed.

Extension lint passed on this attempt, so no rerun was needed. Security-fast and the security-sensitive review passed. ClawSweeper completed the exact-head review on October 16 at 09:47 UTC with zero code findings and no Before merge items; both older findings are resolved. The reported video-perception, platform, and upgrade proof limits remain explicit.

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. agents Agent runtime and tooling extensions: openai size: L labels Oct 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 13, 2026
@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserves video attachments on their owning chat turns, forwards them to explicitly capable Chat Completions providers, and bounds their preflight cost.

Example: Send a 1,415,341-byte MP4 to a Chat Completions model configured with input ["text", "image", "video"].

  • Before: The provider receives no video, or base64 text causes a false context-overflow rejection.
  • After: The request carries one video_url part on the original user message and estimates video independently of base64 length.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The changed payload behavior has shipped-entry-point evidence, both prior findings are resolved, and no actionable code finding remains; CI failure handling still needs completion.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The recorded isolated macOS Gateway flow exercises sessions.create, chat.send, agent.wait, and chat.history against a deterministic provider endpoint, showing exact video bytes on the original current, retained, and queued user turns without attachment duplication or runtime-context contamination. Source comparison preserves that behavior through the reviewed head. Real local image/text controls pass; video perception and Windows/Linux coverage on the repaired head are expressly unclaimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A configured video-capable reply model receives no clip or rejects it before sending because encoded video is counted as prompt text.
Reason: The change restores an existing authored capability within the established provider boundary, and feature-history owner commits repair the implementation.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete media handoff failure still present on main, resolves both prior findings, and contains useful unique work; exact-head CI admission remains unresolved.

Priority: P2
Reviewed head: 8cdb89b344f45a171be1fa81779d6a7ccdb0c31b

Before merge

None.

Findings

None.

Agent review details

How this fits together

Inbound attachment facts pass through session message projections into a lazy provider context, which the Chat Completions transport converts into the outbound request.

flowchart LR
  A[Inbound video attachment] --> B[Exact message media facts]
  B --> C[Session message projections]
  C --> D[Provider context materialization]
  D --> E[Chat Completions conversion]
  E --> F[Bounded preflight estimate]
  F --> G[Configured provider endpoint]
Loading

Technical review

Best possible solution:

Land the focused handoff repair after the existing CI admission workflow resolves the red gate.

Do we have a high-confidence way to reproduce the issue?

Current-main source exposes the missing handoff and dropped runtime facts, consistent with the recorded baseline Gateway captures; this review ran no target code.

Is this the best way to solve the issue?

The repair addresses the producer and transport boundaries, removes reinjection machinery, and preserves the approved provider-only video contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 51042e8c1a27.

Provenance checked

  • Runtime media-fact carrier keeps the original intent (a95c059: Carry ordered attachment facts without changing serialized or model-visible bytes.)
  • Provider-only video types keeps the original intent (226c699: Allow explicit provider video support while keeping canonical runtime and plugin harness contracts image-only.)
  • Provider context handoff lifecycle changes intended behavior with a stated reason (7eed2c3: Materialize video through a closure-bound provider handoff rather than widening canonical messages; the PR explains replacing destructive consumption with call-local memoization.)
  • Attachment dispositions and remote URLs keeps the original intent (82ba647: Record an explicit outcome for every attachment rather than silently losing media.)
  • Shared Chat Completions request assembly keeps the original intent (a9676bd: Keep direct and managed Completions request shaping under the shared assembly owner.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 226c699 adds packages/ai/src/provider-types.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 226c699a23f1; files: packages/ai/src/provider-types.ts)

PR surface

Source +38, Tests +391, Docs +1, Config +1, Other +1. Total +432 across 31 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 18 220 182 +38
Tests 9 431 40 +391
Docs 1 1 0 +1
Config 1 1 0 +1
Generated 0 0 0 0
Other 2 2 1 +1
Total 31 655 223 +432

Review metrics

Metric Value Why it matters
Production versus test changes Production +220/-182; tests +431/-40 Production growth supports the provider capability projection and handoff; tests cover distinct session-conversion, transport, package-export, and omission contracts.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 session-state: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The failure affects explicitly configured video-capable Chat Completions models, with a bounded provider and attachment scope.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (7 earlier review cycles)
  • reviewed 2026-10-13T10:06:25.196Z sha 3de16ab8a60c54d59cf6dadaf6d1f486ec652d38 :: needs real behavior proof before merge. :: [P2] Select the attachment owner using canonical message provenance | [P2] Clear cached media facts when the latest user turn has no media | [P2] Reconcile the registry test with the approved video contract
  • reviewed 2026-10-14T02:08:28.916Z sha 094ca4f50f1e15ff1840433cdd91e8e6d5d09407 :: needs real behavior proof before merge. :: [P2] Exclude projected runtime-context rows from media injection | [P2] Keep video values outside canonical runtime model inputs
  • reviewed 2026-10-14T07:27:08.490Z sha a3a01f8a84baf13909598cbe980df88a7b6754a9 :: needs real behavior proof before merge. :: [P2] Exclude projected runtime-context rows from media injection | [P2] Keep video values outside canonical runtime model inputs
  • reviewed 2026-10-14T08:10:01.485Z sha c7ddb211c63f72e1f05714e45dad80c33889ab6a :: needs real behavior proof before merge. :: [P2] Exclude projected runtime-context rows from media injection | [P2] Keep video values outside canonical runtime model inputs
  • reviewed 2026-10-14T08:42:55.981Z sha 7c24da47fc74455fe2c12044aae2409f674faf44 :: needs real behavior proof before merge. :: [P2] Exclude projected runtime-context rows from media injection | [P2] Keep video values outside canonical runtime model inputs
  • reviewed 2026-10-14T09:10:01.491Z sha 7c24da47fc74455fe2c12044aae2409f674faf44 :: needs real behavior proof before merge. :: [P2] Exclude projected runtime-context rows from media injection | [P2] Keep video values outside canonical runtime model inputs
  • reviewed 2026-10-14T10:05:23.599Z sha b41c66185f94e9febae6fc2a56ddf2a35860839c :: needs real behavior proof before merge. :: [P2] Exclude projected runtime-context rows from media injection | [P2] Keep video values outside canonical runtime model inputs

Reviewed October 16, 2026, 5:47 AM ET / 09:47 UTC (Revision 8).

@evomach

evomach commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Rebased and review fixes landed. Head is now 094ca4f50f1.

1. Rebase. Rebased onto current origin/main (12 commits). Conflicts kept both sides where upstream and this PR add at the same anchor (sessionFork, modelCallSequence).

2. Current-turn fact injection — canonical provenance. Active-turn detection in the media projection now uses the shared isRuntimeContextCarrier structural contract (packages/agent-core/src/harness/messages.js: custom type + details flag). The delimiter-text sniffing called out in review is removed; facts are only re-injected onto the active user row when that row carries none (the session-layer rebuild case this PR targets).

3. No stale re-injection. currentTurnMediaFacts is cleared when a text-only turn replaces the active turn (both the persisted and suppressed-persist paths in attempt-session-prepare.ts), so a previous video turn cannot be re-injected after the turn advances.

4. Model registry contract — provider-only boundary adopted. The canonical widening is reverted: Model.input (llm-core) and the registry runtime projection stay text|image. Current-main's contract fixture (input: ["text","image","video"] → runtime ["text","image"]) settles the intent, and the provider side already carries the rest: ModelDefinitionSchema accepts video in config, prepared catalog entries type input as ModelInputType[], ProviderModel.input (packages/ai/provider-types) uses the full ModelInputContent union, and the openai-completions transcript-transform gate (model.api === "openai-completions" && model.input.includes("video")) already consumes it. Declared video survives only through resolveProviderModelInput (single documented cast at the provider boundary) onto the wire model.

5. Test evidence. Targeted suites: 9 files / 133 tests, all passing — media-facts.persisted, images.replay, attempt-llm-boundary.runtime-facts, runner.video, openai-completions-params, openai-completions-transport, model.inline-provider, attempt-stream-transport, message-transform-stream-wrapper. tsgo:core typecheck clean. The transport suites assert the forwarded video part shape on the outbound request.

6. model-registry.test.ts on this host (heads-up, not this PR). 13 tests fail locally with #<Object> could not be cloned at src/infra/sqlite-worker-client.ts:107 (structured-clone of the worker command payload via plugin-model-catalog.ts). A/B check: with src/agents/sessions/model-registry.ts and packages/llm-core/src/types.ts force-checked-out at origin/main, the same 13 tests fail identically in this worktree — environmental (Windows sqlite-worker path in this checkout), unrelated to this diff.

End-to-end recorded proof (serialized outbound request body for a real video turn against a live OpenAI-compatible endpoint) will be posted separately in this thread once our staging build replays it.

@evomach

evomach commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Recorded end-to-end behavior proof (live gateway → llama.cpp endpoint).

Setup: OpenClaw dev install on Windows against a local llama.cpp server (http://127.0.0.1:5468/v1/chat/completions, model qwen3.8-flash-next-iq3_s), custom provider configured with input: ["text","image","video"].

1. Endpoint reference-shape proof. A direct POST /v1/chat/completions whose user content carries exactly one block {type:"video_url", video_url:{url:"data:video/mp4;base64,..."}} (IMG_5792 clip, ~1.4 MB) returned HTTP 200 with an accurate description at ~8.9k prompt tokens, and again at ~110k tokens of filler context (correct details: Greek appointment-export app, date pickers, status-bar time/battery). The endpoint accepts exactly the part shape this PR makes the transport produce.

2. Pre-fix gateway capture (the bug, live). Diagnostic build, real Telegram video turn (clip IMG_6046, runId 5ac45c0a-71bf-4437-bae9-71822f8b7ed1, active user message index #305):

video probe: canonical=1 converted=0 outbound=0 strictKeys=false stringContent=false
canonical: #305 mime=video/mp4 payload=1425424B  parts=text,video
final: outboundVideos=0 model=qwen3.8-flash-next-iq3_s baseUrl=http://127.0.0.1:5468/v1 messages=308 tools=14

The canonical {type:"video"} block reached buildOpenAICompletionsRequest with the full payload, yet convertMessages emitted 0 video_url parts — the exact failure mode this PR fixes.

3. Post-fix end-to-end pass (blind). With this PR's fix in the dev install (flag on; builds 19ece929d + 940add191), a brand-new clip the model had never seen (runId 95b4260c-8e88-4472-945e-0d778a7e34a6):

message=151/153 activeUser=true resolved=1
videoBlocks=2   (fresh clip + one prior-clip history replay)
endpoint HTTP 200

The model produced an accurate cold description of the blind clip (3D-printed phone stand with two tabs + center cable notch → BF4-skinned wired mouse → full-size Corsair keyboard, RGB blue/pink/green, ending on the G1–G6 macro column), matching ground truth that was sealed to a file before the description was generated. videoBlocks=2 = this turn's block plus the previous turn's block replayed from history — consistent with the turn-scoped fact semantics this PR enforces.

Caveats, stated plainly: the per-turn probe counters above came from transient instrumentation in the dev install (since stripped); no verbatim converted=1 outbound=1 line survived for the green round — its receipts are resolved=1 + videoBlocks=2 + HTTP 200 + sealed-ground-truth perception. The serialized part shape itself is asserted in this PR's test suite (openai-completions-transport.test.ts: { type: "video_url", video_url: { url: "data:video/mp4;base64,Zm9v" } }). One permanent trace line from the current build: provider-context handoff materialized: runId=f8accaf0-aa7c-41ae-bbd4-7083dc94e291 messages=211/213/215 videoBlocks=2 omissionMarkers=6.

A fresh live capture against the final head can be arranged on request (re-instrument + rebuild + a new clip).

@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 14, 2026
@evomach evomach closed this Oct 14, 2026
@evomach evomach reopened this Oct 14, 2026
@evomach
evomach force-pushed the pr/native-video-handoff branch from 7c24da4 to b41c661 Compare October 14, 2026 09:54
@evomach

evomach commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

CI red on attempt.spawn-workspace.context-engine.test.ts is an upstream-main regression, not this PR

The failing node shard (checks-node-changed-compact-large-*, shard core-runtime-infra-storage-state-hosted-7) fails deterministically in the last two CI runs. I A/B-verified it locally against this branch and against plain origin/main (405b128c765):

  • Rebased branch head: same 4 failures — enforces code-mode payload surface from active-agent…, quarantines unsupported tool schemas before creating…, keeps hook prompt context visible while hiding inter… (×2), with expected undefined to be true / expected [] to deeply equal [['healthy_lookup']].
  • Plain origin/main (no PR changes at all): identical 4 failures (4 failed | 21 passed).
  • This PR's round-1 head (a3a01f8a84b, rebased onto cae016bcc12) passed every checks-node-* job in CI (run 38527500201). All subsequent commits on this branch were comment-only (// SAFETY: ratchet annotations, // mock-isolation:) plus one unused-import removal — none can affect runtime behavior.

So the breakage was introduced by main commits landed today (the area saw 3cbbeb08d47 publication-for-managed-children and 70409b38bb9 continuation-skip changes since our previous base). The branch is now rebased onto current origin/main for a clean merge, but these four test failures will persist on any PR until the upstream regression is fixed (main's own CI runs right now are also failing, at preflight).

Everything else on this PR is green: lint, test-types, baseline ratchets (assertion-safety, mock-exports, line-cap, database ratchets), CodeQL, evidence gate, and the full focused suite for the touched code (133/133).

Happy to rebase again once the upstream fix lands.

@evomach
evomach force-pushed the pr/native-video-handoff branch from b41c661 to 902ca04 Compare October 14, 2026 19:59
@evomach

evomach commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Head updated: rebased onto current origin/main (7de67ce7ee); previous red was two external flakes

The last red run on b41c66185f9 had exactly one failing substantive job (checks-node-changed-compact-small-29 / checks-node-core-test-nondist-shard), and it was not this PR's code:

  • test/scripts/vitest-fork-shutdown.test.ts > rejects fixture cancellation by signal and joins descendants — the CI harness's own shutdown fixture raced: Error: ENOENT: no such file or directory, open '.artifacts/vitest-fork-shutdown/vitest-fork-cancellation-XXXX/worker.pid' (fixture pid file gone before the parent read it). This PR touches no files under test/scripts or the shutdown fixtures.

Everything else on that head was green: lint, test-types, baseline ratchets (assertion-safety, mock-exports, line-cap, database ratchets), CodeQL/security shards, evidence gate, Android/iOS scans, and the full focused suite for the touched code.

The branch is now rebased onto current origin/main, which also carries fa3e272e213 (test(agents): use real prompt reports in attempt fixtures) — the upstream change that resolves the attempt.spawn-workspace.context-engine.test.ts failures I A/B-documented earlier (those failed identically on plain main at the time).

One conflict during rebase, in attempt-stream-settle.ts: upstream's thinking-provenance stream wrapper vs this PR's provider-context handoff for boundary transports. Merged by keeping both — the provider-context selection (boundaryStreamFn) is wrapped by the openclawThinkingExplicit options pass-through, preserving both semantics.

New head: 902ca04c549. Fresh CI run in progress.

@evomach

evomach commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Only remaining red: android-test-play hit the 20-minute job timeout (flaky lane, not code)

Fresh run on 902ca04c549 is green everywhere except android-test-play, which was canceled at the 20m0s job limit (The job has exceeded the maximum execution time of 20m0s) - no test assertion failed. This PR touches no Android/Kotlin code. On the previous head (b41c66185f9) the same job passed in 16m05s, so the lane is right at the edge of its budget and times out intermittently. Everything else - lint, test-types, baseline ratchets, node shards (including the previously failing core-test-nondist shard), CodeQL, evidence gate - is green.

Could someone re-run the failed job? Thanks!

@evomach
evomach force-pushed the pr/native-video-handoff branch from 902ca04 to 141338c Compare October 15, 2026 07:59
@evomach

evomach commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Head updated again: rebased onto current origin/main (1f862d19891, clean rebase, no new conflicts) and re-validated locally — all focused suites green, including the settleEmbeddedAttemptStream liveness cases.

This main carries the CI timeout rework (Android test shards now get 24–25 min budgets), so the android-test-play 20-minute cancellation that gated the previous run should not recur on this revision — no manual re-run needed. New head: 141338cddf4.

@evomach

evomach commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

The lint red on this revision is an upstream-main regression (extensions/line), not this PR

check-lint-core-5 fails with exactly one error:

extensions/line/src/send.test.ts:159:40: error: 'messageId' is already declared in the upper scope. (eslint(no-shadow))
  • This PR's diff touches no files under extensions/ at all (only src/agents, src/media-understanding, src/infra, packages/ai).
  • The shadowing pattern (messageIds.map((messageId) under an outer const messageId) is present on plain origin/main (cd3eb90f875) right now — introduced by f41d6b86189 (the dependency-bump sweep, which also bumped oxlint 1.85.0 -> 1.87.0).
  • Locally on this branch: identical single error from oxlint 1.87.0; every other oxlint:extensions:* shard passes.

Happy to carry a one-line rename in this PR to unblock CI if a maintainer prefers that over an upstream fix - say the word.

@evomach

evomach commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Remaining reds on this revision are repo-wide, not from this PR

All three failures reproduce identically on unrelated PRs / plain origin/main:

  1. check-lint-core-5 — no-shadow in extensions/line/src/send.test.ts:159 exists on plain origin/main right now (cd3eb90f875), introduced by f41d6b86189 (dependency sweep, oxlint 1.85.0 -> 1.87.0). This PR touches no extensions/ files. (Earlier comment has details.)

  2. checks-node-compact-small-8-1 — ci-node-test-plan.test.ts > keeps selected Gateway and embedded-agent work within its runner capacity, same assertion expected [] to have a length of 1 but got +0 at test/scripts/ci-node-test-plan.test.ts:3253:

  3. checks-ui-e2e (2/7) — session-management.sidebar.e2e.test.ts (2 tests, expected 4 to be +0):

Nothing in this PR's diff (src/agents, src/media-understanding, src/media, src/infra, packages/ai) can affect these lanes. Happy to rebase/retry whenever trunk greens up.

@evomach
evomach force-pushed the pr/native-video-handoff branch from 2e121ad to d84565f Compare October 15, 2026 16:55
@evomach

evomach commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Behavior-proof addendum: mapping the recorded proof to current head d84565fbbd4

The end-to-end proof comment (#170920 (comment)) was recorded on 2026-10-13/14 against patched dev-install builds 19ece929d + 940add191, before four subsequent rebases of this branch (heads 094ca4f50f1 → … → d84565fbbd4). Status of that proof against the current head:

  • The wire-shape assertions the proof relied on are still part of this PR's suite at d84565fbbd4 (openai-completions-transport.test.ts +46 and openai-completions-params.test.ts +31 vs main), and every CI shard is green on this head (0 fails / 0 pending, verified 2026-10-15 21:55 EEST).
  • The content-part converter (packages/ai/src/openai-completions-messages.ts, {type:"video"} → {type:"video_url", video_url:{url:"data:<mime>;base64,..."}}) was already present on main when the proof was recorded and is unchanged on this head. What this PR contributes at the transport level is the provider-context handoff (resolveProviderContext(...) in streamOpenAICompletionsRequest) plus the boundary fixes that keep the canonical video block and its declared modality intact until that converter runs. The serialized part shape verified in the proof is produced by the same module on d84565fbbd4.
  • The PR's boundary-level contribution against current main (media-fact carrier contract, turn-scoped fact semantics, provider-boundary video modality preservation) is intact and green.
  • The live gateway→llama.cpp capture itself was not re-run on d84565fbbd4; as offered in the original comment, a fresh capture can be arranged on request.

The caveats stated in the original comment remain accurate as written: the transient probe counters were stripped after recording, no verbatim converted=1 outbound=1 line survived for the green round (its receipts stay resolved=1 + videoBlocks=2 + HTTP 200 + sealed-ground-truth perception), and the one permanent on-disk trace line is the 2026-10-13 gateway log entry runId=f8accaf0-aa7c-41ae-bbd4-7083dc94e291 messages=211/213/215 videoBlocks=2 omissionMarkers=6.

steipete and others added 3 commits October 15, 2026 23:58
Merge main and carry existing media facts through runtime projections. Resolve
one provider context per stream call, keep declared video in the typed
Completions projection, and bound video preflight independently of base64 size.

Co-authored-by: evomach <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 16, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@steipete steipete self-assigned this Oct 16, 2026
@steipete
steipete merged commit cd486ed into openclaw:main Oct 16, 2026
201 of 205 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

vincentkoc added a commit that referenced this pull request Oct 16, 2026
* commit 'ac03ca0b6d26a7dc55d0d262e40d2549631b1ea7': (25 commits)
  fix: apply shared plugin model policy to decisions (#156621)
  perf: shortlist transcript relevance scores before metadata reads (#174058)
  fix: strip standalone trailing NO_REPLY from replies (#171990)
  fix(ci): avoid repeated discovery during changed-test planning (#174069)
  fix(sqlite): preserve transaction outcomes when warnings throw (#157151)
  fix(ai): native video handoff to chat-completions providers + preflight video cost (#170920)
  fix(litellm): image generation fails when the backend returns image URLs (#173508)
  test(memory,gateway,infra,subagents): remove low-value tests (batch d152) (#174034)
  perf(memory): bound derived worker snapshot and pricing retention (#174067)
  fix(test): reduce eager imports during test startup (#174056)
  refactor(codex): share lifecycle preflight fixtures (#174062)
  test(gateway,matrix,agents,ui): remove low-value tests (batch d150) (#174025)
  perf(infra): batch usage refresh maintenance (#174050)
  fix(gateway): revert cold session list worker regression (#174052)
  refactor(config): consolidate browser meeting configuration (#173947)
  fix(cron): keep global-session deliveries on the selected agent (#173855)
  test(compaction): assert structured stale-writer failure (#174064)
  fix(cli): local terminal chat sends model requests without the configured proxy (#173530)
  test(ui): restore bootstrap preference locale after each case (#174065)
  fix: download session files through the development proxy (#173973)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…ht video cost (openclaw#170920)

* fix(media-understanding): hand video to native vision models

* fix(media-understanding): trust configured native video models

* fix(ai): materialize provider context for completions transports

OpenAI Completions ignored provider context handoff, so native video materialization never reached llm-local payloads. The handoff is now memoized and resolved by the transport before request construction.

* fix(agents): install provider context for boundary transports

* fix(ai): estimate video parts as fixed cost in completions preflight

The proxy-like context guard JSON-stringified video_url parts, counting their base64 data URIs as text (~480k estimated tokens for a 1 MB clip) and rejecting the request before it reached the server, which bills the same clip as ~4k frame tokens. Mirrors the existing image_url fixed estimate. Regression test: a 1.05 MB clip passes the guard on a 64k-token context.

* fix(agents): resolve provider-context handoff through @openclaw/ai package specifier

Relative imports of packages/ai/src/provider-types.js made tsdown bundle a second copy of the module into the unified dist, so PROVIDER_CONTEXT_HANDOFF (a unique symbol) existed twice: the embedded wrapper set the copy bundled as llm-*.mjs while the completions transport imported the copy from packages/ai/dist. options[HANDOFF] was therefore always undefined in the transport, the handoff was never consumed, and the prune-time 'video omitted' marker survived into provider payloads. Import the published subpath so both sides share one symbol instance.

* fix(agents): rehydrate non-canonical user media facts at provider materialization

Freshly drained/queued runtime user turns can reach model context with facts only in top-level media fields; transcript append canonicalizes the DB copy but the in-memory copy stayed unprojected, so active-turn video (and any legacy-shaped media) was omitted while later history replays resolved fine. Fall back to canonicalizePersistedUserMessageMedia when neither runtime symbols nor __openclaw carry facts, and trace unprojected media under OPENCLAW_DEBUG_VIDEO_HANDOFF=1. Pinned by replay tests (top-level media fact and bake-then-rematerialize round trip).

* fix(agents): carry non-enumerable runtime media facts across LLM boundary copies

The probe round proved the provider pass sees a different active-user copy than hydration: normalizeMessagesForLlmBoundary re-projects user messages (runtime-context escape, timestamp stamping, blocked-metadata strip) with Object.assign/spread, which drops the non-enumerable symbol fact carriers, and inserts the runtime-context carrier so the active index shifts. The active turn's video therefore reached provider materialization with zero fact channels while history copies (enumerable __openclaw) survived. Re-attach runtime facts on every boundary projection; pinned by attempt-llm-boundary.runtime-facts.test.ts (fails without the fix).

* fix(agents): inject current-turn media facts into provider transcript copies

Census round proved provider-pass user rows are session-layer rebuilds with zero fact carriers (runtime symbols stripped, __openclaw absent), so the active turn's video could never materialize in its own turn regardless of hydration. The run now stashes canonical facts from onUserMessagePersisted/Suppressed on attempt.currentTurnMediaFacts and materializeProviderContext re-injects them onto the active user row when no channel resolves. activeUserIndex also skips runtime-context wrapper rows (fixes 336->337 shift). Two regression tests in images.replay.test.ts.

* fix(tsconfig): map @openclaw/ai/provider-types so worker-graph tests build

* fix(media): skip runtime prompt symbol tags on frozen hydrated message copies

* fix(models): preserve declared video input modality through model resolution

resolveProviderModelInput and the sessions model-registry filtered configured input lists to text|image, so a model declaring input:[text,image,video] reached the openai-completions transport without video. provider-transcript-transform then evaluated supportsVideo=false and replaced the active video block with the '(video omitted: provider does not support video input)' placeholder - canonical=1/converted=0 in the probe. Widen llm-core Model.input to include video, keep video in both resolvers, regression test for inline providers.

* fix(agents): bind media-fact injection to canonical carrier contract and clear stale turn facts

Review follow-up: active-turn detection now uses the shared isRuntimeContextCarrier structural check instead of delimiter-text sniffing, and currentTurnMediaFacts is cleared when a text-only turn replaces the active turn so previous-turn video cannot be re-injected.

* fix(models): keep video capability at the provider boundary

Review alignment: revert the canonical model-input widening (llm-core Model.input and the registry runtime projection stay text/image per the current-main contract test). Declared video now survives only through resolveProviderModelInput onto the provider runtime model, where the provider-side ProviderModel.input union (packages/ai/provider-types) and the openai-completions transport gate already legitimize it. Config schema (ModelDefinitionSchema) and prepared catalog entries already carried video on main; no canonical contract change is needed for native video on custom openai-completions providers.

* fix(ci): satisfy lint and test-type shards

Remove the boolean-to-boolean compare in the native-video capability check and a dead assignment in the media projection; annotate provider-scope video fixtures in the transport/params/inline/replay tests with provider-boundary downcasts matching production.

* fix(ci): annotate provider-boundary assertions for safety ratchet

Add // SAFETY: invariant comments to the new provider-boundary type assertions so the assertion-safety baseline ratchet holds, and drop the now-unused processCompletionsStream import from the transport test (oxlint no-unused-vars).

* test(ci): annotate prepared-catalog mock isolation

check:test-mock-exports requires first-party mock factories to spread the real module or carry a // mock-isolation: reason; the runner.video fixture intentionally stubs the prepared model catalog.

* chore: shrink assertion allowance after native video repair

* test(media): assert normalized queued text at the video boundary

* test(media): complete model fixtures and wrapper imports

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: evomach <[email protected]>
@evomach
evomach deleted the pr/native-video-handoff branch October 24, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants