Summary
When Memory is passed globally to VoltAgent (via the memory option) instead of directly to each Agent, the generateTitle configuration is silently ignored and conversation titles are never generated.
Root Cause
Agent constructor resolves memory and builds titleGenerator at construction time:
// agent.ts
const resolvedMemory = this.memoryConfigured
? options.memory
: AgentRegistry.getInstance().getGlobalAgentMemory();
const titleGenerator = this.createConversationTitleGenerator(
resolvedMemory instanceof Memory ? resolvedMemory : undefined,
);
this.memoryManager = new MemoryManager(this.id, resolvedMemory, {}, this.logger, titleGenerator);
When agents are instantiated as module-level singletons (common pattern), AgentRegistry.getGlobalAgentMemory() returns undefined because VoltAgent hasn't run yet. So titleGenerator is set to undefined.
Later, VoltAgent calls agent.__setDefaultMemory(memory), which only updates conversationMemory in MemoryManager — it does not re-initialize titleGenerator:
// MemoryManager.setMemory
setMemory(memory: Memory | false): void {
if (memory instanceof Memory) {
this.conversationMemory = memory; // titleGenerator is never updated
}
}
Steps to Reproduce
// agents/assistant.ts — module-level singleton, no memory passed
export default new Agent({ name: "assistant", model: "...", tools });
// index.ts
const memory = new Memory({ storage: adapter, generateTitle: true });
new VoltAgent({
agents: { assistant },
memory, // passed globally
});
With this setup, generateTitle has no effect. All conversations receive the fallback title "Conversation".
Expected Behavior
__setDefaultMemory should also update (or lazily initialize) titleGenerator so that generateTitle works regardless of whether memory is passed globally or per-agent.
Workaround
Pass memory directly to each Agent constructor:
export function createAssistant(memory: Memory) {
return new Agent({ name: "assistant", model: "...", tools, memory });
}
Environment
Summary
When
Memoryis passed globally toVoltAgent(via thememoryoption) instead of directly to eachAgent, thegenerateTitleconfiguration is silently ignored and conversation titles are never generated.Root Cause
Agentconstructor resolves memory and buildstitleGeneratorat construction time:When agents are instantiated as module-level singletons (common pattern),
AgentRegistry.getGlobalAgentMemory()returnsundefinedbecauseVoltAgenthasn't run yet. SotitleGeneratoris set toundefined.Later,
VoltAgentcallsagent.__setDefaultMemory(memory), which only updatesconversationMemoryinMemoryManager— it does not re-initializetitleGenerator:Steps to Reproduce
With this setup,
generateTitlehas no effect. All conversations receive the fallback title"Conversation".Expected Behavior
__setDefaultMemoryshould also update (or lazily initialize)titleGeneratorso thatgenerateTitleworks regardless of whether memory is passed globally or per-agent.Workaround
Pass
memorydirectly to eachAgentconstructor:Environment
@voltagent/corelatest