Repository navigation
refactor: drop redundant session.last_turn_id in favor of last_turn_details (AGE-2584) - #1128
Merged
Merged
Conversation
…etails (AGE-2584) Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: 8e4c4ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
chiragjn
reviewed
Oct 22, 2026
chiragjn
left a comment
Member
There was a problem hiding this comment.
Please make sure we roll this out in next release once all writes to this field will stop completely - even from older live pods.
We do not want turn creation to break during rollout phase
hary73
marked this pull request as ready for review
October 22, 2026 11:06
hary73
requested review from
debajyoti-truefoundry,
heerambavi1998 and
thesujai
as code owners
October 22, 2026 11:06
Contributor
Author
Sure, will ensure this goes in the next release |
chiragjn
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sessions now carry
last_turn_details({ id, state: { status } }), which makes thesession.last_turn_idcolumn redundant. This PR removes it and reads the session tip fromlast_turn_details.ideverywhere.Linear: AGE-2584
Changes
SessionRecorddropslast_turn_id;previous_turn_id: 'auto'resolution, cancel-turn, first-turn title derivation, and the defaultlistSessionEventsanchor now uselast_turn_details.id.createTurnstop writinglast_turn_id; the column is removed from the DB types and the SQLite select list.20261022_000001_drop_session_last_turn_id(Postgres + SQLite) drops the column;downre-adds and backfills it fromlast_turn_details.id.last_turn_idquery param and page-token field on list-events (they're the listing anchor, not the column), so no API/SDK change.@truefoundry/trueforge-coreand@truefoundry/trueforge.Deploy note: the column is dropped in the same release that stops using it. During a rolling deploy, old pods still select
last_turn_idand will fail on session reads once the migration runs. If that window matters, we can split the migration into a follow-up release.How was this tested?
pnpm typecheck,pnpm format:check, ESLint on changed filespnpm test:trueforge-core,pnpm test:trueforgepnpm test:store:local(Postgres 17 + SQLite store contract suites, including migrations)Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locally (typecheck, format, and the suites above were run; full build/lint left to CI)packages/trueforge-sdk,python/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
Schema migration plus session-tip reads/writes across stores and APIs; rolling deploy can break old binaries that still SELECT last_turn_id after the migration runs.
Overview
Removes the redundant
session.last_turn_idcolumn and treatslast_turn_details.idas the single source of truth for the session tip.SessionRecordno longer exposeslast_turn_id.previous_turn_id: 'auto', cancel-current-turn, first-turn title derivation, and the defaultlistSessionEventsanchor now readlast_turn_details?.id(or null/undefined when there is no tip). In-memory, Postgres, and SQLitecreateTurnonly advancelast_turn_details; session mappers and DB types drop the column.Adds migration
20261022_000001_drop_session_last_turn_idfor Postgres and SQLite (withdownthat re-adds and backfills fromlast_turn_details.id). Patch changeset for@truefoundry/trueforge-coreand@truefoundry/trueforge.Unchanged:
listSessionEventsstill accepts alast_turn_idquery param and encodes it in page tokens—that name refers to the listing anchor, not the removed column, so wire/API shape is unchanged.Deploy note: dropping the column in the same release as code that stops selecting it can break older pods during a rolling deploy if the migration runs first.
Reviewed by Cursor Bugbot for commit 0dec1f9. Bugbot is set up for automated code reviews on this repo. Configure here.