From 3c230b43a399185d66065b0514774c243b744218 Mon Sep 17 00:00:00 2001 From: odilitime Date: Wed, 18 Dec 2024 23:46:30 +0000 Subject: [PATCH] postgres needs the user to exist before you can add a participant --- packages/core/src/runtime.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/core/src/runtime.ts b/packages/core/src/runtime.ts index 7d37f1ee35..2ba5f016b4 100644 --- a/packages/core/src/runtime.ts +++ b/packages/core/src/runtime.ts @@ -234,6 +234,10 @@ export class AgentRuntime implements IAgentRuntime { this.#conversationLength = opts.conversationLength ?? this.#conversationLength; + + if (!opts.databaseAdapter) { + throw new Error("No database adapter provided"); + } this.databaseAdapter = opts.databaseAdapter; // use the character id if it exists, otherwise use the agentId if it is passed in, otherwise use the character name this.agentId = @@ -249,15 +253,14 @@ export class AgentRuntime implements IAgentRuntime { this.agentId, this.character.name, this.character.name - ); - this.ensureParticipantExists(this.agentId, this.agentId); + ).then(() => { + // postgres needs the user to exist before you can add a participant + this.ensureParticipantExists(this.agentId, this.agentId); + }); elizaLogger.success("Agent ID", this.agentId); this.fetch = (opts.fetch as typeof fetch) ?? this.fetch; - if (!opts.databaseAdapter) { - throw new Error("No database adapter provided"); - } this.cacheManager = opts.cacheManager;