Skip to content

Commit 21c63c4

Browse files
authored
Merge pull request #1219 from odilitime/postgres-fix
fix: postgres needs the user to exist before you can add a participant
2 parents 392efc6 + 97d474f commit 21c63c4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/core/src/runtime.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ export class AgentRuntime implements IAgentRuntime {
234234

235235
this.#conversationLength =
236236
opts.conversationLength ?? this.#conversationLength;
237+
238+
if (!opts.databaseAdapter) {
239+
throw new Error("No database adapter provided");
240+
}
237241
this.databaseAdapter = opts.databaseAdapter;
238242
// use the character id if it exists, otherwise use the agentId if it is passed in, otherwise use the character name
239243
this.agentId =
@@ -249,15 +253,14 @@ export class AgentRuntime implements IAgentRuntime {
249253
this.agentId,
250254
this.character.name,
251255
this.character.name
252-
);
253-
this.ensureParticipantExists(this.agentId, this.agentId);
256+
).then(() => {
257+
// postgres needs the user to exist before you can add a participant
258+
this.ensureParticipantExists(this.agentId, this.agentId);
259+
});
254260

255261
elizaLogger.success("Agent ID", this.agentId);
256262

257263
this.fetch = (opts.fetch as typeof fetch) ?? this.fetch;
258-
if (!opts.databaseAdapter) {
259-
throw new Error("No database adapter provided");
260-
}
261264

262265
this.cacheManager = opts.cacheManager;
263266

0 commit comments

Comments
 (0)