Fix bridge compression history handling (#726)
* feat(bridge): refactor compression to use DB history and add structured logging - Extract buildDbHistory() to share message loading between buildCompressedHistory and forceCompressBridgeHistory - forceCompressBridgeHistory now reads from local DB instead of using Python-provided messages, ensuring consistency with api_server path - Pass sessionId to compressor for snapshot-aware compression - Add force_compress flag to bridge chat requests - Add bridgeLogger structured logging for compression lifecycle - Simplify schemas, session-sync, and providers Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix bridge compression history handling --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -41,7 +41,7 @@ describe('Hermes schema initialization', () => {
|
||||
expect(usageCols.some(c => c.name === 'output_tokens')).toBe(true)
|
||||
})
|
||||
|
||||
it('preserves existing data when syncing schemas', async () => {
|
||||
it('preserves existing data when adding safe schema columns', async () => {
|
||||
const { initAllHermesTables, USAGE_TABLE, USAGE_SCHEMA } =
|
||||
await import('../../packages/server/src/db/hermes/schemas')
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('Hermes schema initialization', () => {
|
||||
// Insert test data
|
||||
db.prepare(`INSERT INTO "${USAGE_TABLE}" (session_id, created_at) VALUES (?, ?)`).run('test-session', Date.now())
|
||||
|
||||
// Run initialization (should sync schema)
|
||||
// Run initialization (should add safe missing columns)
|
||||
expect(() => initAllHermesTables()).not.toThrow()
|
||||
|
||||
// Verify data is preserved
|
||||
@@ -59,7 +59,7 @@ describe('Hermes schema initialization', () => {
|
||||
expect(row).toBeTruthy()
|
||||
expect(row.session_id).toBe('test-session')
|
||||
|
||||
// Verify new columns were added
|
||||
// Verify safe new columns were added
|
||||
const cols = db.prepare(`PRAGMA table_info("${USAGE_TABLE}")`).all() as Array<{ name: string }>
|
||||
expect(cols.some(c => c.name === 'input_tokens')).toBe(true)
|
||||
expect(cols.some(c => c.name === 'output_tokens')).toBe(true)
|
||||
|
||||
Reference in New Issue
Block a user