feat: ai context compaction backend#23276
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| if (row === undefined) { | ||
| throw new Error('Failed to create thread compaction'); | ||
| } |
There was a problem hiding this comment.
throw new Error('Failed to create thread compaction') uses a plain Error instead of a typed error class. Per the backend rules, errors should be categorised using the existing error classes in errors.ts (or a new one created if none fits). Use an appropriate class such as UnexpectedServerError or create a new one.
| if (row === undefined) { | |
| throw new Error('Failed to create thread compaction'); | |
| } | |
| if (row === undefined) { | |
| throw new UnexpectedServerError('Failed to create thread compaction'); | |
| } | |
Spotted by Graphite (based on custom rule: packages/backend rules)
Is this helpful? React 👍 or 👎 to let us know.
|
Docs PR opened: lightdash/mintlify-docs#667 Added a new AI agents guide page documenting thread context compaction, including how it works and how to enable it. |
246e4c9 to
d6993bb
Compare
🧪 Test Selection✅ Tests that will run
⏭️ Tests skipped (no relevant file changes detected)
|
|
Your preview environment pr-23276 has been deployed. Preview environment endpoints are available at: |
d6993bb to
272c2ce
Compare
| export async function down(knex: Knex): Promise<void> { | ||
| await knex.schema.dropTableIfExists(AI_THREAD_COMPACTION_TABLE_NAME); | ||
|
|
||
| if (await knex.schema.hasColumn(AI_PROMPT_TABLE_NAME, 'token_usage')) { | ||
| await knex.schema.alterTable(AI_PROMPT_TABLE_NAME, (table) => { | ||
| table.dropColumn('token_usage'); | ||
| }); | ||
| } |
There was a problem hiding this comment.
The down migration drops the ai_thread_compaction table AND drops the token_usage column from ai_prompt. Deleting columns and tables are explicitly listed as dangerous operations that must not appear in migrations, because they are destructive and cannot be safely run while old code is still live. Remove the column drop (and ideally the table drop) from the down function, or at minimum make the column nullable rather than dropping it.
| export async function down(knex: Knex): Promise<void> { | |
| await knex.schema.dropTableIfExists(AI_THREAD_COMPACTION_TABLE_NAME); | |
| if (await knex.schema.hasColumn(AI_PROMPT_TABLE_NAME, 'token_usage')) { | |
| await knex.schema.alterTable(AI_PROMPT_TABLE_NAME, (table) => { | |
| table.dropColumn('token_usage'); | |
| }); | |
| } | |
| export async function down(knex: Knex): Promise<void> { | |
| // Intentionally left as a no-op. | |
| // Dropping columns and tables are destructive operations that cannot be safely | |
| // run while old code is still live. The table and column are left in place to | |
| // avoid data loss and to prevent breaking running instances. | |
Spotted by Graphite (based on custom rule: Migration guide)
Is this helpful? React 👍 or 👎 to let us know.
272c2ce to
688496c
Compare
Preview Environment🌐 URL: https://lightdash-preview-pr-23276.lightdash.okteto.dev 📋 Logs: View in GCP Console 🔧 SSH: |
688496c to
0dccf22
Compare
0dccf22 to
8ac0f34
Compare
Merge activity
|
|
🎉 This PR is included in version 0.2985.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |

Closes:
Description: