Skip to content

Commit

Permalink
Merge pull request elizaOS#1219 from odilitime/postgres-fix
Browse files Browse the repository at this point in the history
fix: postgres needs the user to exist before you can add a participant
  • Loading branch information
monilpat authored Dec 19, 2024
2 parents 392efc6 + 97d474f commit 21c63c4
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 21c63c4

Please sign in to comment.