diff --git a/lib/eliza/runtime-factory.ts b/lib/eliza/runtime-factory.ts index f79b0d1e3..ab4093d3c 100644 --- a/lib/eliza/runtime-factory.ts +++ b/lib/eliza/runtime-factory.ts @@ -123,9 +123,10 @@ class RuntimeCache { } async set( - agentId: string, + cacheKey: string, runtime: AgentRuntime, characterName: string, + actualAgentId: UUID, ): Promise { // Evict oldest if at capacity if (this.cache.size >= this.MAX_SIZE) { @@ -133,15 +134,15 @@ class RuntimeCache { } const now = Date.now(); - this.cache.set(agentId, { + this.cache.set(cacheKey, { runtime, lastUsed: now, createdAt: now, - agentId: agentId as UUID, + agentId: actualAgentId, characterName, }); elizaLogger.debug( - `[RuntimeCache] Cached runtime: ${characterName} (${agentId})`, + `[RuntimeCache] Cached runtime: ${characterName} (${actualAgentId}, key=${cacheKey})`, ); } @@ -448,7 +449,7 @@ export class RuntimeFactory { await this.initializeRuntime(runtime, character, agentId); await this.waitForMcpServiceIfNeeded(runtime, filteredPlugins); - await runtimeCache.set(cacheKey, runtime, character.name); + await runtimeCache.set(cacheKey, runtime, character.name, agentId); edgeRuntimeCache .markRuntimeWarm(agentId as string, {