Skip to content

fix(migration): import oversized legacy conversations (K-brain v0.107.11, retry old 413s) - #1142

Merged
xiaozhou26 merged 2 commits into
mainfrom
fix/legacy-import-too-large
Nov 3, 2026
Merged

xiaozhou26 merged 2 commits into
mainfrom
fix/legacy-import-too-large

Conversation

@xiaozhou26

Copy link
Copy Markdown
Contributor

Linked issue

Closes #1141

Summary

Long legacy conversations (mostly ones with inline images) failed to migrate with 413 "超出单次导入限制". Each conversation goes to K-brain in one request whose source_metadata repeats the conversation, so these requests exceeded K-brain's 64 MiB import cap.

  • K-brain v0.107.11 (fix(backend): 旧版对话导入上限从 64 MiB 放宽到 512 MiB K-brain#84) raises the legacy import cap to 512 MiB. This PR pins it.
  • Retry once after the upgrade. A 413 is recorded as a deterministic failure and skipped at startup, so conversations that already failed would otherwise stay unmigrated until the user clicked "导入旧版对话". too_large records now store the cap they were seen under (limitBytes). Records without the current cap are retried once at startup. A 413 under the new cap is skipped as before, so huge conversations are not re-uploaded on every launch.

The import request itself is unchanged, so already-imported conversations keep their content fingerprint.

Change scope

  • Modules: agent-gui, release
  • Key paths:
    • crates/agent-gui/src/lib/kbrain/historyMigrationFailures.ts: LEGACY_IMPORT_MAX_BODY_BYTES, limitBytes, and the startup skip rule
    • crates/agent-gui/src/lib/kbrain/historyMigration.ts: records limitBytes on too_large
    • scripts/release/kbrain.lock.json: K-brain v0.107.11 (b143a827). The sha256 values come from the release SHA256SUMS.

Screenshots / preview

N/A. No UI change. Labeled governance-exempt.

Verification

  • pnpm typecheck and pnpm lint (agent-gui): pass
  • Migration tests (kbrain-history-migration*.test.mjs): 37/37 pass. The new test covers both cases: a record without the cap marker is retried once and cleared on success; a record with the current cap is skipped.
  • node --test scripts/release/prepare-kbrain.test.mjs scripts/release/verify-kbrain-packaging.test.mjs: 11/11 pass
  • K-brain v0.107.11 release: 13 assets, not draft or prerelease. All 8 pinned hashes were checked against SHA256SUMS.

Pre-submit checklist

  • A requirement issue is linked (or this is a trivial fix that needs no issue, as explained in the summary).
  • Synced with the target branch; no merge conflicts.
  • The change is focused, with no unrelated modifications.
  • No secrets, tokens, or personal data included.
  • Docs are updated for changes affecting user behavior, deployment, or configuration.

…rt cap

K-brain now accepts legacy imports up to 512 MiB (was 64 MiB). Conversations
that already failed with 413 are recorded as deterministic failures and
skipped at startup, so after the upgrade they would stay unmigrated until the
user clicked "Import old conversations".

Record the cap a too_large failure was seen under; startup retries records
without the current cap once, and later 413s are skipped as before.
@xiaozhou26 xiaozhou26 added the governance-exempt Skip PR governance checks label Nov 3, 2026
@xiaozhou26
xiaozhou26 merged commit a54b63a into main Nov 3, 2026
26 of 27 checks passed
@xiaozhou26
xiaozhou26 deleted the fix/legacy-import-too-large branch November 3, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

governance-exempt Skip PR governance checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 旧版对话迁移失败:超出单次导入限制

1 participant