Skip to content

Commit

Permalink
postgres needs the user to exist before you can add a participant
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime committed Dec 18, 2024
1 parent 105025a commit 3c230b4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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;

Expand Down

0 comments on commit 3c230b4

Please sign in to comment.