Skip to content

feat: analyze frames and storyboards with Kimi K3 - #219

Merged
devhims merged 2 commits into
mainfrom
feat/kimi-visual-analyst
Oct 21, 2026
Merged

devhims merged 2 commits into
mainfrom
feat/kimi-visual-analyst

Conversation

@devhims

@devhims devhims commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Problem / Motivation

Session 8eb3885c asked which piece stood on h2 in two chess frames. The visual analyst (GLM 5.3 Flash) reported h2 as empty, and on reanalysis as a black king next to the white king, an illegal position. The frames show a black queen on h2 at 1:48 and the white king on h2 at 2:04. Replays through the production analyst reproduced the misreading in every run, and neither prompt wording, upscaling nor one-frame requests changed it. Other vision models on the same frames and prompts read it correctly.

What changed

Frame and storyboard analysis now use Kimi K3 on Fireworks, selected by a new AGENT_VISUAL_MODEL setting. An empty value keeps GLM, so rolling back is a configuration change.

  • Kimi K3 uses native low reasoning, the Priority tier, and 1,024 tokens of reasoning headroom. Its Priority prices are recorded, so visual analysis is not costed at GLM rates.
  • It fails over to DeepSeek V4.1 Flash, the existing backup, through the run's single fallback switch that GLM already uses. A stall of either model moves the rest of that run to DeepSeek, and a resumed run restores the switch from its recorded fallback event.
  • Other roles are unchanged.

Benchmark

All five deployed candidates ran through the unchanged production analysts with production provider options, three runs per task. Single frames covered 8 tasks: chess, on-screen text, name captions, a frame with no caption, subtitles and objects. Storyboards covered 23 tasks over 11 sheets of 6 videos: news, chess, a product launch, an Excel tutorial, cooking and a slide talk, including two-sheet requests.

Model Frames Storyboards Storyboard median / p95 Storyboard cost per call Failed calls
Kimi K3 99% 86% 3.1 s / 5.6 s $0.0105 0 of 93
Kimi K3 Fast 99% 86% 2.0 s / 3.9 s $0.0123 0 of 93
GLM 5.3 Flash (previous) 86% 67% 2.3 s / 3.7 s $0.0004 0 of 93
DeepSeek V4.1 Flash 91% 64% 8.4 s / 16.2 s $0.0016 6 of 93
Qwen 3.8 Max 92% 24% 7.6 s / 10.6 s $0.0168 54 of 93

GLM failed every run on reading small slide text in storyboard tiles ("AI OS", a product name, a "Reaction" label) and invented a caption name. Kimi K3 still misses some cases: no model detected a flipped chess board, and Kimi missed one cooking step that DeepSeek found. Kimi K3 Fast matches its accuracy but costs more and has no Priority tier.

Tests

Platform build, generated skill and documentation checks passed. Platform tests: 2,118 passed, 59 skipped. Workers integration: 417 passed. New tests cover visual model routing, the empty-value rollback, unknown model rejection, Kimi pricing, and Kimi failover through the shared switch, including a run restored from its fallback event. A live frame analysis through production createAgentModel reached Kimi K3 with these settings and read the session's frames correctly in 4.7 seconds.

Compatibility

No migration. AGENT_VISUAL_MODEL is a new plain variable in wrangler.jsonc. Regenerating Worker types also records the Polar product ID already committed in wrangler.jsonc. Frame analysis costs about $0.01 per call instead of $0.0004, a few cents per run that analyzes images, inside the existing per-run model budget.

GLM 5.3 Flash misread a chess position in a production session (a black queen as an empty square, a rook or a king) and could not read most small on-screen text in storyboard tiles. Through the production analysts, Kimi K3 scored 99% on single frames and 86% on storyboard sheets, against 86% and 67% for GLM, with no failed calls.

AGENT_VISUAL_MODEL selects the visual analyst model on Fireworks, set to kimi-k3; an empty value keeps GLM. Kimi K3 uses native low reasoning with the Priority tier and is priced at its Priority rates. It fails over to DeepSeek V4.1 Flash with its own run-level switch, so a visual model stall never moves other roles off GLM and a GLM outage leaves visual analysis on Kimi. The run deadline and cost check stay shared.

Regenerating worker types also picks up the Polar product ID already committed in wrangler.jsonc.
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
video2ctx-web Ready Ready Preview Oct 21, 2026 3:48am UTC

devhims commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

Review of b9f99b5

Verdict: CHANGES NEEDED. One P2 recovery/isolation defect remains; pricing and ordinary routing look consistent.

P2 — Persist and restore the visual fallback separately

platform/src/agents/model.ts:48–54 initializes visual fallback to false in a WeakMap and forwards diagnostics to the shared callback. However, agent-runtime-do.ts:1763–1770 still persists every fallback as model.fallback and restores the presence of any such event as shared fallback=true, without distinguishing the visual role.

Reproduction with mocked provider responses and the runtime's exact persistence/restore predicate: Kimi returns 503 → visual DeepSeek succeeds → original shared fallback remains false → reconstruct the state from the emitted visual fallback event → shared fallback becomes true, a recreated visual model starts Kimi again, and recreated Agent Core starts DeepSeek. The memory updater also reconstructs state this way, so a visual outage moves that unrelated GLM role even without a restart.

Impact: resumed runs lose the visual outage switch, retry the unhealthy primary, and incorrectly move otherwise healthy text roles to the backup. Persist/restore distinct visual and general fallback domains while retaining shared deadline, cost guard and diagnostics. Add recovery and memory-updater isolation coverage; the new same-object isolation tests do not exercise this boundary.

P3 — Update the remaining GLM visual-model documentation

reference/engineering/AGENT_PATHS_AND_LIMITS.md:283 still says storyboard/frame analysis starts with GLM, contradicting the Kimi configuration and updated opening. Nonblocking, but misleading during operations/debugging.

Independent verification

  • PASS: platform Vitest suite, 2,119 passed / 59 skipped at this exact head.
  • PASS: focused routing/failover/budget suite, 64 tests (subset, not additional to the full-suite count).
  • PASS: platform tsc --noEmit after restoring local package dependency links; initial missing-module errors were environment setup, not code failures.
  • PASS: generated documentation check.
  • DEFECT REPRODUCED: standalone no-network mocked-provider probe described above. It reproduces the runtime restore mapping, not a real Durable Object restart or live outage.
  • GitHub checks for this head are green, including platform integration and dashboard/auth E2E; Mintlify intentionally skipped. CI run.
  • Kimi Priority rates match Fireworks pricing: $3.75 input / $0.375 cached / $18.75 output per million. Analyst accounting uses actual response model IDs.

No paid inference or production test was run for this review. Accuracy/latency/average-cost benchmark numbers remain author-reported, not independently reproduced. No code was implemented, pushed, merged or deployed.

The separate visual fallback switch lived only in memory, while the runtime records every fallback as a model.fallback event and rebuilds one run-wide flag from it on resume and in the memory updater. A Kimi-only fallback was therefore restored as a run-wide one, moving healthy text roles to DeepSeek and retrying the stalled visual model.

Kimi K3 now uses the run's single switch, like GLM: a stall of either moves the rest of the run to DeepSeek, and a resumed run restores that consistently. This removes the separate state and its tests and corrects the remaining GLM visual-model documentation.

devhims commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

Re-review of 23cd69a

Verdict: APPROVE. No material findings remain under the revised, explicitly documented shared-fallback policy.

The previous P2 is resolved by removing the separate WeakMap switch rather than persisting independent domains. Kimi and GLM now intentionally share one run-wide switch: a qualifying failure moves subsequent calls to DeepSeek, and recovered state agrees. My prior mocked-provider Kimi-503/recovery probe now selects DeepSeek consistently for resumed visual, core and memory roles. The previous P3 stale GLM visual-model paragraph is corrected too.

Independent verification at this head:

  • Platform suite: 2,118 passed / 59 skipped.
  • Focused model/visual-failover suite: 60 passed, a subset of the full suite.
  • Real Durable Object fallback-restoration checks: 2 passed, with 97 unrelated tests filtered out. These existing tests use a GLM event; the separate actual-wrapper Kimi probe covers the Kimi path using mocked provider responses and the restore predicate.
  • Shared budget guards, diagnostic callbacks and updated/expired deadlines passed independent probes.
  • TypeScript, generated-documentation check and diff whitespace check passed; tracked checkout clean.
  • All latest-head GitHub checks are green: CI run.

This approves code correctness against the new shared-switch contract, not the former isolation behavior. No paid inference, live outage or production visual-accuracy retest was performed. Benchmark accuracy/latency/cost figures remain author-reported. No merge or deployment performed.

@devhims
devhims merged commit 88e0605 into main Oct 21, 2026
10 checks passed
@devhims
devhims deleted the feat/kimi-visual-analyst branch October 21, 2026 03:54

This branch was successfully deployed

1 active deployment
Preview — 23cd69af Deployed Oct 21, 2026 by vercel[bot]
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