Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
TypeScript aiai-agentsai-memoryanthropicartificial-intelligencechromadbclaudeclaude-agent-sdkclaude-agentsclaude-codeclaude-code-pluginclaude-skillsembeddingslong-term-memorymem0memory-engineopenmemoryragsqlitesupermemory
fix(search): strip concepts filter in searchSessions (#6717)
Raphael Malikian920582b769a6
diff --git a/src/services/sqlite/SessionSearch.ts b/src/services/sqlite/SessionSearch.tsindex 4aed32afc..52cd784fc 100644--- a/src/services/sqlite/SessionSearch.ts+++ b/src/services/sqlite/SessionSearch.ts@@ -745,6 +745,7 @@ export class SessionSearch {]);const filterOptions = { ...filters };delete filterOptions.type;+ delete filterOptions.concepts;const filterParams: any[] = [];const filterClause = this.buildFilterClause(filterOptions, filterParams, 's');const orderClause = orderBy === 'date_asc'@@ -841,6 +842,7 @@ export class SessionSearch {if (!query) {const filterOptions = { ...filters };delete filterOptions.type;+ delete filterOptions.concepts;const filterClause = this.buildFilterClause(filterOptions, params, 's');if (!filterClause) {// No query text and no filters: nothing to match, so return an empty@@ -871,6 +873,7 @@ export class SessionSearch {if (this._fts5Available || this.canReadFtsIndex('session_summaries_fts')) {const filterOptions = { ...filters };delete filterOptions.type;+ delete filterOptions.concepts;const filterClause = this.buildFilterClause(filterOptions, params, 's');const orderClause = orderBy === 'date_asc'diff --git a/tests/services/sqlite/search-sessions-concepts-filter.test.ts b/tests/services/sqlite/search-sessions-concepts-filter.test.tsnew file mode 100644index 000000000..2817c7a58--- /dev/null+++ b/tests/services/sqlite/search-sessions-concepts-filter.test.ts@@ -0,0 +1,72 @@+import { describe, it, expect, beforeEach, afterEach } from 'bun:test';+import { SessionStore } from '../../../src/services/sqlite/SessionStore.js';+import { SessionSearch } from '../../../src/services/sqlite/SessionSearch.js';++// session_summaries has no `concepts` column, but searchSessions() passed the+// caller-supplied `concepts` filter straight into buildFilterClause(), which+// emits `json_each(s.concepts)` — a hard `SQLiteError: no such column:+// s.concepts` on every path (filter-only, substring, FTS). The `type` filter+// was already stripped the same way; `concepts` must be stripped too, matching+// how SearchManager already removes it before calling searchSessions().+describe('searchSessions with a concepts filter', () => {+ let store: SessionStore;+ let search: SessionSearch;++ function seedSummary(memorySessionId: string, project: string, request: string): void {+ const sdkId = store.createSDKSession(`${memorySessionId}-raw`, project, 'prompt');+ store.ensureMemorySessionIdRegistered(sdkId, memorySessionId);+ store.importSessionSummary({+ memory_session_id: memorySessionId,+ project,+ request,+ investigated: null,+ learned: null,+ completed: null,+ next_steps: null,+ files_read: null,+ files_edited: null,+ notes: null,+ prompt_number: 1,+ discovery_tokens: 0,+ created_at: new Date(1_700_000_000_000).toISOString(),+ created_at_epoch: 1_700_000_000_000,+ });+ }++ beforeEach(() => {+ store = new SessionStore(':memory:');+ search = new SessionSearch(store.db);+ seedSummary('sum-cache', 'concepts-project', 'refactor the cache layer');+ seedSummary('sum-login', 'concepts-project', 'update the login flow');+ seedSummary('sum-cjk', 'concepts-project', '重构用户身份验证的会话');+ });++ afterEach(() => {+ store.close();+ });++ it('FTS path: ignores the concepts filter instead of crashing', () => {+ const results = search.searchSessions('cache', { project: 'concepts-project', concepts: ['cache'] });+ expect(results.map(r => r.request)).toEqual(['refactor the cache layer']);+ });++ it('filter-only path: ignores the concepts filter instead of crashing', () => {+ const results = search.searchSessions(undefined, { project: 'concepts-project', concepts: ['cache'] });+ expect(results.map(r => r.request).sort()).toEqual([+ 'refactor the cache layer',+ 'update the login flow',+ '重构用户身份验证的会话',+ ]);+ });++ it('substring path: ignores the concepts filter instead of crashing', () => {+ const results = search.searchSessions('用户身份', { project: 'concepts-project', concepts: ['cache'] });+ expect(results.map(r => r.request)).toEqual(['重构用户身份验证的会话']);+ });++ it('still applies the project filter and tolerates the type filter', () => {+ expect(search.searchSessions('cache', { project: 'other-project', concepts: ['cache'] })).toEqual([]);+ const withType = search.searchSessions('cache', { project: 'concepts-project', type: 'decision', concepts: ['cache'] });+ expect(withType.map(r => r.request)).toEqual(['refactor the cache layer']);+ });+});