Uh oh!
There was an error while loading. Please reload this page.
feat: add agent sesison migrate endpoint - #487
Conversation
🦋 Changeset detectedLatest commit: 11510b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| ) | ||
| .execute(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Per-row queries inside import loops
Low Severity
The import issues a separate insert for every turn, thread, context batch, capability map, and event list. That is an N+1 write pattern inside one transaction instead of batched inserts.
Triggered by project rule: @truefoundry/trueforge review rules
Reviewed by Cursor Bugbot for commit 0817072. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f7dc19a. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.


Summary
add agent sesison migrate
Closes #NA
Changes
add agent sesison migrate
How was this tested?
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Medium Risk
Admin-gated but can bulk-write production session data; incorrect snapshots could corrupt history, though normal session runtime paths are unchanged.
Overview
Adds an ops/backfill admin API to import a single historical agent session (session row, turns, threads, context logs, capability state, and events) into Postgres in one transaction.
POST
/api/v1/settings/sessions/importis mounted under the existing settings admin surface (withAdminAuth). The body is a loose Zod-validated snapshot (session+ at least oneturn). Ifsession_idalready exists, the handler returns 200 withimported: false; on a successful insert it returns 201 withimported: true. Standalone/SQLite deployments wiresessionSnapshotImporterasundefinedand respond with 501.Implementation is
PostgresSessionSnapshotImporter, which usesON CONFLICT DO NOTHINGon the session row and rebuilds per-threadcontext_idswith append-only deduplication viaisContextPrefix. OpenAPI docs and a changeset are included; the route is markedx-fern-ignore(not SDK-published).Reviewed by Cursor Bugbot for commit 11510b8. Bugbot is set up for automated code reviews on this repo. Configure here.