Update agent.js

This commit is contained in:
Sweaterdog 2025-02-27 21:12:02 -08:00 committed by GitHub
parent f14f86a518
commit 15eb0fd1c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -91,6 +91,8 @@ export class Agent {
this._setupEventHandlers(save_data, init_message);
this.startEvents();
// this.task.initBotTask();
if (!load_mem) {
this.task.initBotTask();
}
@ -156,10 +158,10 @@ export class Agent {
};
if (save_data?.self_prompt) {
let prompt = save_data.self_prompt;
// add initial message to history
this.history.add('system', prompt);
await this.self_prompter.start(prompt);
if (init_message) {
this.history.add('system', init_message);
}
await this.self_prompter.handleLoad(save_data.self_prompt, save_data.self_prompting_state);
}
if (save_data?.last_sender) {
this.last_sender = save_data.last_sender;
@ -193,7 +195,7 @@ export class Agent {
shutUp() {
this.shut_up = true;
if (this.self_prompter.on) {
if (this.self_prompter.isActive()) {
this.self_prompter.stop(false);
}
convoManager.endAllConversations();
@ -259,7 +261,7 @@ export class Agent {
await this.history.add(source, message);
this.history.save();
if (!self_prompt && this.self_prompter.on) // message is from user during self-prompting
if (!self_prompt && this.self_prompter.isActive()) // message is from user during self-prompting
max_responses = 1; // force only respond to this message, then let self-prompting take over
for (let i=0; i<max_responses; i++) {
if (checkInterrupt()) break;