Skip to content

Commit fa2ef7c

Browse files
committed
fix: Filter Duplicate imports
1 parent 1b04c5b commit fa2ef7c

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

packages/core/src/runtime.ts

+20-12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
type Memory,
4747
} from "./types.ts";
4848
import { stringToUuid } from "./uuid.ts";
49+
import _ from "lodash";
4950

5051
/**
5152
* Represents the runtime environment for an agent, handling message processing,
@@ -340,11 +341,13 @@ export class AgentRuntime implements IAgentRuntime {
340341

341342
this.token = opts.token;
342343

343-
this.plugins = [
344+
const allPlugins = [
344345
...(opts.character?.plugins ?? []),
345346
...(opts.plugins ?? []),
346347
];
347348

349+
this.plugins = _.uniqBy(allPlugins, "name");
350+
348351
this.plugins.forEach((plugin) => {
349352
plugin.actions?.forEach((action) => {
350353
this.registerAction(action);
@@ -410,22 +413,27 @@ export class AgentRuntime implements IAgentRuntime {
410413
}
411414

412415
async stop() {
413-
elizaLogger.debug('runtime::stop - character', this.character)
414-
// stop services, they don't have a stop function
416+
elizaLogger.debug("runtime::stop - character", this.character);
417+
// stop services, they don't have a stop function
415418
// just initialize
416419

417-
// plugins
420+
// plugins
418421
// have actions, providers, evaluators (no start/stop)
419422
// services (just initialized), clients
420423

421-
// client have a start
422-
for(const cStr in this.clients) {
423-
const c = this.clients[cStr]
424-
elizaLogger.log('runtime::stop - requesting', cStr, 'client stop for', this.character.name)
425-
c.stop()
426-
}
427-
// we don't need to unregister with directClient
428-
// don't need to worry about knowledge
424+
// client have a start
425+
for (const cStr in this.clients) {
426+
const c = this.clients[cStr];
427+
elizaLogger.log(
428+
"runtime::stop - requesting",
429+
cStr,
430+
"client stop for",
431+
this.character.name
432+
);
433+
c.stop();
434+
}
435+
// we don't need to unregister with directClient
436+
// don't need to worry about knowledge
429437
}
430438

431439
/**

0 commit comments

Comments
 (0)