Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): preserve trailing-colon chat ids
Josuécafe048e9d86
diff --git a/mcp-host/src/core/conversation/__tests__/inMemoryConversationStore.test.ts b/mcp-host/src/core/conversation/__tests__/inMemoryConversationStore.test.tsindex e341c2dab..e10e2dcec 100644--- a/mcp-host/src/core/conversation/__tests__/inMemoryConversationStore.test.ts+++ b/mcp-host/src/core/conversation/__tests__/inMemoryConversationStore.test.ts@@ -161,6 +161,16 @@ describe('InMemoryConversationStore', () => {])})+ it('preserves a trailing colon in a chat id under an unscoped prefix', async () => {+ store.set('u-1:rpc:agent-x:chat-trailing:', makeConversation('u-1'))++ const summaries = await store.listSessionSummariesByPrefix('u-1:rpc:')++ expect(summaries.map(session => [session.agent, session.chatId])).toEqual([+ ['agent-x', 'chat-trailing:'],+ ])+ })+it('supports an agent literally named rpc when the scoped agent is explicit', async () => {store.set('u-1:rpc:rpc:chat-1', makeConversation('u-1'))diff --git a/mcp-host/src/core/conversation/persistence/__tests__/sqliteConversationStore.test.ts b/mcp-host/src/core/conversation/persistence/__tests__/sqliteConversationStore.test.tsindex fe031085f..347f876c3 100644--- a/mcp-host/src/core/conversation/persistence/__tests__/sqliteConversationStore.test.ts+++ b/mcp-host/src/core/conversation/persistence/__tests__/sqliteConversationStore.test.ts@@ -400,6 +400,27 @@ describe('SqliteConversationStore — session summary listing', () => {}})+ it('preserves a trailing colon in a chat id under an unscoped prefix', async () => {+ const handle = await freshStore({ cacheSize: 4 })+ try {+ const manager = new ConversationManager(handle.store)+ const key = 'u-1:rpc:agent-x:chat-trailing:'+ const conversation = await manager.getOrCreate(key)+ await manager.startTurn(conversation, 'hello', 'task-1')+ await manager.completeTurn(conversation, 'done')+ await handle.persistQueue.drainSessionKey(key)+ handle.store['cache'].clear()++ const summaries = await handle.store.listSessionSummariesByPrefix('u-1:rpc:')++ expect(summaries.map(session => [session.agent, session.chatId])).toEqual([+ ['agent-x', 'chat-trailing:'],+ ])+ } finally {+ await handle.shutdown()+ }+ })+it('fails closed instead of treating unsafe limits as unbounded reads', async () => {const handle = await freshStore({ cacheSize: 4 })try {diff --git a/mcp-host/src/db/statements.ts b/mcp-host/src/db/statements.tsindex 474656246..142fa1b7d 100644--- a/mcp-host/src/db/statements.ts+++ b/mcp-host/src/db/statements.ts@@ -248,7 +248,8 @@ export function prepareStatements(db: Database): PreparedStatements {(@agent_scoped = 0AND instr(substr(session_key, length(@prefix_start) + 1), ':') > 1- AND substr(session_key, -1) <> ':'+ AND instr(substr(session_key, length(@prefix_start) + 1), ':')+ < length(substr(session_key, length(@prefix_start) + 1))))AND (