openloops 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harness/agent-state.d.ts +3 -1
- package/dist/harness/agent-state.js +6 -1
- package/dist/harness/agent-state.mjs +6 -1
- package/dist/harness/utils/activity.d.ts +1 -0
- package/dist/harness/utils/activity.js +37 -0
- package/dist/harness/utils/activity.mjs +14 -0
- package/dist/loops/agi/loop.js +10 -4
- package/dist/loops/agi/loop.mjs +10 -4
- package/dist/loops/agi/skills/reasoning-engine.d.ts +1 -0
- package/dist/loops/agi/skills/reasoning-engine.js +4 -2
- package/dist/loops/agi/skills/reasoning-engine.mjs +4 -2
- package/dist/loops/shared/skills/fast-responder.d.ts +1 -0
- package/dist/loops/shared/skills/fast-responder.js +4 -2
- package/dist/loops/shared/skills/fast-responder.mjs +4 -2
- package/dist/services/tasks/entities/agent-task.entity.d.ts +2 -0
- package/dist/services/tasks/entities/agent-task.entity.js +1 -1
- package/dist/services/tasks/entities/agent-task.entity.mjs +1 -1
- package/docs/agent.md +1 -1
- package/docs/loops.md +4 -2
- package/package.json +1 -1
|
@@ -29,12 +29,14 @@ export declare class AgentState {
|
|
|
29
29
|
stopRequested?: boolean | undefined;
|
|
30
30
|
currentActivity?: CurrentActivity | undefined;
|
|
31
31
|
private activityListener?;
|
|
32
|
+
private activityFromModel;
|
|
32
33
|
static fromJSON(props?: AgentStateProps): AgentState;
|
|
33
34
|
constructor(status?: AgentStatus | undefined, language?: string | undefined, lastError?: AgentError | undefined, activeTaskId?: string | undefined, stopRequested?: boolean | undefined, currentActivity?: CurrentActivity | undefined);
|
|
34
35
|
toJSON(): AgentStateProps;
|
|
35
36
|
setLanguage(language?: string): void;
|
|
36
37
|
onActivityChange(listener?: ActivityListener): void;
|
|
37
|
-
|
|
38
|
+
get hasModelActivity(): boolean;
|
|
39
|
+
setCurrentActivity(currentActivity: CurrentActivity, source?: 'system' | 'model'): void;
|
|
38
40
|
setStatus(status: AgentStatus): void;
|
|
39
41
|
setActiveTaskId(taskId?: string): void;
|
|
40
42
|
setLastError(lastError?: AgentError): void;
|
|
@@ -46,6 +46,7 @@ class AgentState {
|
|
|
46
46
|
stopRequested;
|
|
47
47
|
currentActivity;
|
|
48
48
|
activityListener;
|
|
49
|
+
activityFromModel = false;
|
|
49
50
|
static fromJSON(props = {}) {
|
|
50
51
|
return new AgentState(
|
|
51
52
|
props.status,
|
|
@@ -72,9 +73,13 @@ class AgentState {
|
|
|
72
73
|
onActivityChange(listener) {
|
|
73
74
|
this.activityListener = listener;
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
get hasModelActivity() {
|
|
77
|
+
return this.activityFromModel;
|
|
78
|
+
}
|
|
79
|
+
setCurrentActivity(currentActivity, source = "system") {
|
|
76
80
|
const changed = this.currentActivity !== currentActivity;
|
|
77
81
|
this.currentActivity = currentActivity;
|
|
82
|
+
this.activityFromModel = source === "model";
|
|
78
83
|
if (changed) this.activityListener?.(currentActivity);
|
|
79
84
|
}
|
|
80
85
|
setStatus(status) {
|
|
@@ -23,6 +23,7 @@ class AgentState {
|
|
|
23
23
|
stopRequested;
|
|
24
24
|
currentActivity;
|
|
25
25
|
activityListener;
|
|
26
|
+
activityFromModel = false;
|
|
26
27
|
static fromJSON(props = {}) {
|
|
27
28
|
return new AgentState(
|
|
28
29
|
props.status,
|
|
@@ -49,9 +50,13 @@ class AgentState {
|
|
|
49
50
|
onActivityChange(listener) {
|
|
50
51
|
this.activityListener = listener;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
get hasModelActivity() {
|
|
54
|
+
return this.activityFromModel;
|
|
55
|
+
}
|
|
56
|
+
setCurrentActivity(currentActivity, source = "system") {
|
|
53
57
|
const changed = this.currentActivity !== currentActivity;
|
|
54
58
|
this.currentActivity = currentActivity;
|
|
59
|
+
this.activityFromModel = source === "model";
|
|
55
60
|
if (changed) this.activityListener?.(currentActivity);
|
|
56
61
|
}
|
|
57
62
|
setStatus(status) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cleanActivity(value: unknown): string | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var activity_exports = {};
|
|
20
|
+
__export(activity_exports, {
|
|
21
|
+
cleanActivity: () => cleanActivity
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(activity_exports);
|
|
24
|
+
const MAX_ACTIVITY_LENGTH = 80;
|
|
25
|
+
const RESERVED_ACTIVITIES = ["running", "stopped"];
|
|
26
|
+
function cleanActivity(value) {
|
|
27
|
+
if (typeof value !== "string") return void 0;
|
|
28
|
+
const text = value.replace(/[`*_#>\[\]{}<>|\\]/g, " ").replace(/\s+/g, " ").trim();
|
|
29
|
+
if (!text || RESERVED_ACTIVITIES.includes(text.toLowerCase())) return void 0;
|
|
30
|
+
if (text.length <= MAX_ACTIVITY_LENGTH) return text;
|
|
31
|
+
const cut = text.slice(0, MAX_ACTIVITY_LENGTH).replace(/\s+\S*$/, "").trim();
|
|
32
|
+
return cut ? `${cut}...` : void 0;
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
cleanActivity
|
|
37
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "../../chunk-CF3WOMB3.mjs";
|
|
2
|
+
const MAX_ACTIVITY_LENGTH = 80;
|
|
3
|
+
const RESERVED_ACTIVITIES = ["running", "stopped"];
|
|
4
|
+
function cleanActivity(value) {
|
|
5
|
+
if (typeof value !== "string") return void 0;
|
|
6
|
+
const text = value.replace(/[`*_#>\[\]{}<>|\\]/g, " ").replace(/\s+/g, " ").trim();
|
|
7
|
+
if (!text || RESERVED_ACTIVITIES.includes(text.toLowerCase())) return void 0;
|
|
8
|
+
if (text.length <= MAX_ACTIVITY_LENGTH) return text;
|
|
9
|
+
const cut = text.slice(0, MAX_ACTIVITY_LENGTH).replace(/\s+\S*$/, "").trim();
|
|
10
|
+
return cut ? `${cut}...` : void 0;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
cleanActivity
|
|
14
|
+
};
|
package/dist/loops/agi/loop.js
CHANGED
|
@@ -26,6 +26,7 @@ var import_agent_task = require("../../services/tasks/entities/agent-task.entity
|
|
|
26
26
|
var import_skills = require("../shared/skills");
|
|
27
27
|
var import_grounding = require("../../harness/utils/grounding.js");
|
|
28
28
|
var import_reasoning_engine = require("./skills/reasoning-engine");
|
|
29
|
+
var import_activity = require("../../harness/utils/activity.js");
|
|
29
30
|
const MAX_TURNS = 20;
|
|
30
31
|
const MAX_TOOL_CALLS = 40;
|
|
31
32
|
const WARN_SAME_TOOL = 3;
|
|
@@ -49,7 +50,7 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
49
50
|
return "agi";
|
|
50
51
|
}
|
|
51
52
|
get version() {
|
|
52
|
-
return "1.
|
|
53
|
+
return "1.8.0";
|
|
53
54
|
}
|
|
54
55
|
get author() {
|
|
55
56
|
return {
|
|
@@ -83,6 +84,8 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
83
84
|
});
|
|
84
85
|
ctx.chat.state?.setLanguage(result.detected_language);
|
|
85
86
|
if (!result.can_answer) {
|
|
87
|
+
const activity = (0, import_activity.cleanActivity)(result.activity);
|
|
88
|
+
if (activity) ctx.chat.state?.setCurrentActivity(activity, "model");
|
|
86
89
|
harness.setNextNode(this.nodes.reasoning_engine);
|
|
87
90
|
} else {
|
|
88
91
|
ctx.chat.state?.setStatus(import_harness.AgentStatus.IDLE);
|
|
@@ -91,7 +94,7 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
async reasoningEngine(ctx, harness) {
|
|
94
|
-
ctx.chat.state?.setCurrentActivity("Thinking...");
|
|
97
|
+
if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity("Thinking...");
|
|
95
98
|
const task = ctx.task ?? ctx.chat.createTask(ctx.currentMessage);
|
|
96
99
|
task.answerQuestion(ctx.currentMessage);
|
|
97
100
|
const streak = task.sameToolStreak;
|
|
@@ -124,7 +127,10 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
124
127
|
const language = typeof result.language === "string" ? result.language.trim().toLowerCase() : "";
|
|
125
128
|
if (/^[a-z]{2}$/.test(language)) ctx.chat.state?.setLanguage(language);
|
|
126
129
|
const { rawText, ...callInfo } = result.callInfo;
|
|
127
|
-
|
|
130
|
+
const activity = (0, import_activity.cleanActivity)(result.activity);
|
|
131
|
+
if (activity) ctx.chat.state?.setCurrentActivity(activity, "model");
|
|
132
|
+
else if (ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity("Thinking...");
|
|
133
|
+
task.addTurn({ ...result, activity }, {
|
|
128
134
|
author: "reasoning_engine",
|
|
129
135
|
declaredTools: catalog.tools.map((tool) => tool.name),
|
|
130
136
|
invoker: (0, import_agent_task.findInvoker)(catalog.tools),
|
|
@@ -148,7 +154,7 @@ class AgiLoop extends import_harness.AgentLoop {
|
|
|
148
154
|
const blocked = ready.filter((action) => harness.requiresApproval(action));
|
|
149
155
|
const runnable = ready.filter((action) => !blocked.includes(action));
|
|
150
156
|
if (runnable.length) {
|
|
151
|
-
ctx.chat.state?.setCurrentActivity(`Running ${runnable.map((action) => action.name).join(", ")}...`);
|
|
157
|
+
if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity(`Running ${runnable.map((action) => action.name).join(", ")}...`);
|
|
152
158
|
await Promise.all(runnable.map((action) => harness.runAction(action, { blockDuplicates: BLOCK_DUPLICATES })));
|
|
153
159
|
}
|
|
154
160
|
if (blocked.length) {
|
package/dist/loops/agi/loop.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { findInvoker } from "../../services/tasks/entities/agent-task.entity.js"
|
|
|
4
4
|
import { fastResponder } from "../shared/skills";
|
|
5
5
|
import { ungroundedIdentifiers, UNGROUNDED_PHRASE } from "../../harness/utils/grounding.js";
|
|
6
6
|
import { reasoningEngine } from "./skills/reasoning-engine";
|
|
7
|
+
import { cleanActivity } from "../../harness/utils/activity.js";
|
|
7
8
|
const MAX_TURNS = 20;
|
|
8
9
|
const MAX_TOOL_CALLS = 40;
|
|
9
10
|
const WARN_SAME_TOOL = 3;
|
|
@@ -27,7 +28,7 @@ class AgiLoop extends AgentLoop {
|
|
|
27
28
|
return "agi";
|
|
28
29
|
}
|
|
29
30
|
get version() {
|
|
30
|
-
return "1.
|
|
31
|
+
return "1.8.0";
|
|
31
32
|
}
|
|
32
33
|
get author() {
|
|
33
34
|
return {
|
|
@@ -61,6 +62,8 @@ class AgiLoop extends AgentLoop {
|
|
|
61
62
|
});
|
|
62
63
|
ctx.chat.state?.setLanguage(result.detected_language);
|
|
63
64
|
if (!result.can_answer) {
|
|
65
|
+
const activity = cleanActivity(result.activity);
|
|
66
|
+
if (activity) ctx.chat.state?.setCurrentActivity(activity, "model");
|
|
64
67
|
harness.setNextNode(this.nodes.reasoning_engine);
|
|
65
68
|
} else {
|
|
66
69
|
ctx.chat.state?.setStatus(AgentStatus.IDLE);
|
|
@@ -69,7 +72,7 @@ class AgiLoop extends AgentLoop {
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
async reasoningEngine(ctx, harness) {
|
|
72
|
-
ctx.chat.state?.setCurrentActivity("Thinking...");
|
|
75
|
+
if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity("Thinking...");
|
|
73
76
|
const task = ctx.task ?? ctx.chat.createTask(ctx.currentMessage);
|
|
74
77
|
task.answerQuestion(ctx.currentMessage);
|
|
75
78
|
const streak = task.sameToolStreak;
|
|
@@ -102,7 +105,10 @@ class AgiLoop extends AgentLoop {
|
|
|
102
105
|
const language = typeof result.language === "string" ? result.language.trim().toLowerCase() : "";
|
|
103
106
|
if (/^[a-z]{2}$/.test(language)) ctx.chat.state?.setLanguage(language);
|
|
104
107
|
const { rawText, ...callInfo } = result.callInfo;
|
|
105
|
-
|
|
108
|
+
const activity = cleanActivity(result.activity);
|
|
109
|
+
if (activity) ctx.chat.state?.setCurrentActivity(activity, "model");
|
|
110
|
+
else if (ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity("Thinking...");
|
|
111
|
+
task.addTurn({ ...result, activity }, {
|
|
106
112
|
author: "reasoning_engine",
|
|
107
113
|
declaredTools: catalog.tools.map((tool) => tool.name),
|
|
108
114
|
invoker: findInvoker(catalog.tools),
|
|
@@ -126,7 +132,7 @@ class AgiLoop extends AgentLoop {
|
|
|
126
132
|
const blocked = ready.filter((action) => harness.requiresApproval(action));
|
|
127
133
|
const runnable = ready.filter((action) => !blocked.includes(action));
|
|
128
134
|
if (runnable.length) {
|
|
129
|
-
ctx.chat.state?.setCurrentActivity(`Running ${runnable.map((action) => action.name).join(", ")}...`);
|
|
135
|
+
if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity(`Running ${runnable.map((action) => action.name).join(", ")}...`);
|
|
130
136
|
await Promise.all(runnable.map((action) => harness.runAction(action, { blockDuplicates: BLOCK_DUPLICATES })));
|
|
131
137
|
}
|
|
132
138
|
if (blocked.length) {
|
|
@@ -25,7 +25,7 @@ var import_skill = require("../../../skills/skill.js");
|
|
|
25
25
|
var import_shared_rules = require("../../../skills/shared/shared-rules.js");
|
|
26
26
|
const reasoningEngine = new import_skill.Skill({
|
|
27
27
|
name: "reasoning_engine",
|
|
28
|
-
version: "2.
|
|
28
|
+
version: "2.5.0",
|
|
29
29
|
description: "Continuous reasoning cycle of the agent: reads the situation or the results of its last actions, rewrites its working state and decides the next actions, including the final answer.",
|
|
30
30
|
temperature: 0.3,
|
|
31
31
|
systemRole: true,
|
|
@@ -39,6 +39,7 @@ const reasoningEngine = new import_skill.Skill({
|
|
|
39
39
|
"STATE: Your state is your working memory and the harness returns it to you in the next cycle. Rewrite it completely in every response, carrying forward what still matters. Use these keys, each a short text: 'objective' (what the user wants, in your own words), 'progress' (what is done and learned so far, citing refs), 'tried' (what you attempted that failed or gave nothing, so you never repeat it), 'expecting' (what you expect these actions to return) and 'next' (what you will do once you have it).",
|
|
40
40
|
`LEARNED: 'learned' is an optional list of {"key": "...", "value": "..."} with the facts you will need in later cycles and must not lose: entities with their exact identifiers (for example the customer or document the user chose, and its id), schemas of tools you will call, and decisions of the user. Add only what is new. The harness keeps it and returns all of it in HARNESS.known in every cycle, so you do not need to copy it into the state. Before an action that targets an entity, use the one in HARNESS.known, and never replace it with a different one unless the user asks. Before calling a tool, take its argument names from HARNESS.schemas when it is listed there.`,
|
|
41
41
|
`ACTIONS: 'actions' is a list of objects like {"tool": "<exact tool name>", "arguments": {...}}. The tool must be one of the names in your tool list. Copy the name character by character, including the server prefix of external tools (like 'server__tool'), which is part of the name. The only thing you may drop is a leading 'functions.'. The arguments must match its schema. You cannot call tools natively: you only ask for them through actions. Independent actions in the same response run in parallel; dependent ones go in later responses. Never invent tool names or arguments.`,
|
|
42
|
+
"ACTIVITY: 'activity' is optional. It is shown to the user while the actions you ask for run and while you think about their results, until your next response. Write one short sentence, around ten words, in the language of the conversation (the same as 'language'), in plain words that say what you are doing and what you will do with the results, for example 'Buscando tus gastos de vuelos de agosto' or 'Sumando los cargos para darte el total'. Never mention tool names, ids, refs or technical terms, never include amounts or personal data, and do not promise a result. Leave it out when your actions only deliver the final answer.",
|
|
42
43
|
"NEVER_EMPTY: 'actions' always has at least one action. 'reasoning' and 'state' are never shown to the user, so writing there that you will answer or summarize delivers nothing. As soon as you have what you need, your action is 'respond' with the complete final answer, written in that same response.",
|
|
43
44
|
`LOOP: After your actions run, the next message you receive is {"OBSERVATIONS": [...]} with one entry per action (ref, tool, status, output or error). Continue from there. You finish the task only with a 'respond' action, which delivers your final answer; use it alone or with actions whose results you no longer need.`,
|
|
44
45
|
"HARNESS_NOTICES: A message may contain a 'HARNESS' key with notices from your body, such as the remaining budget, a warning, a stop reason, 'known' (the facts kept for you, including the answers of the user) or 'schemas' (the arguments of the tools you have already seen). Obey them.",
|
|
@@ -88,7 +89,8 @@ const reasoningEngine = new import_skill.Skill({
|
|
|
88
89
|
next: "string"
|
|
89
90
|
},
|
|
90
91
|
actions: [{ tool: "string", arguments: "object" }],
|
|
91
|
-
learned: [{ key: "string", value: "string" }]
|
|
92
|
+
learned: [{ key: "string", value: "string" }],
|
|
93
|
+
activity: "string"
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -3,7 +3,7 @@ import { Skill } from "../../../skills/skill.js";
|
|
|
3
3
|
import { FORMATTING, LATEX_FORMATTING, CITATION_FORMATTING } from "../../../skills/shared/shared-rules.js";
|
|
4
4
|
const reasoningEngine = new Skill({
|
|
5
5
|
name: "reasoning_engine",
|
|
6
|
-
version: "2.
|
|
6
|
+
version: "2.5.0",
|
|
7
7
|
description: "Continuous reasoning cycle of the agent: reads the situation or the results of its last actions, rewrites its working state and decides the next actions, including the final answer.",
|
|
8
8
|
temperature: 0.3,
|
|
9
9
|
systemRole: true,
|
|
@@ -17,6 +17,7 @@ const reasoningEngine = new Skill({
|
|
|
17
17
|
"STATE: Your state is your working memory and the harness returns it to you in the next cycle. Rewrite it completely in every response, carrying forward what still matters. Use these keys, each a short text: 'objective' (what the user wants, in your own words), 'progress' (what is done and learned so far, citing refs), 'tried' (what you attempted that failed or gave nothing, so you never repeat it), 'expecting' (what you expect these actions to return) and 'next' (what you will do once you have it).",
|
|
18
18
|
`LEARNED: 'learned' is an optional list of {"key": "...", "value": "..."} with the facts you will need in later cycles and must not lose: entities with their exact identifiers (for example the customer or document the user chose, and its id), schemas of tools you will call, and decisions of the user. Add only what is new. The harness keeps it and returns all of it in HARNESS.known in every cycle, so you do not need to copy it into the state. Before an action that targets an entity, use the one in HARNESS.known, and never replace it with a different one unless the user asks. Before calling a tool, take its argument names from HARNESS.schemas when it is listed there.`,
|
|
19
19
|
`ACTIONS: 'actions' is a list of objects like {"tool": "<exact tool name>", "arguments": {...}}. The tool must be one of the names in your tool list. Copy the name character by character, including the server prefix of external tools (like 'server__tool'), which is part of the name. The only thing you may drop is a leading 'functions.'. The arguments must match its schema. You cannot call tools natively: you only ask for them through actions. Independent actions in the same response run in parallel; dependent ones go in later responses. Never invent tool names or arguments.`,
|
|
20
|
+
"ACTIVITY: 'activity' is optional. It is shown to the user while the actions you ask for run and while you think about their results, until your next response. Write one short sentence, around ten words, in the language of the conversation (the same as 'language'), in plain words that say what you are doing and what you will do with the results, for example 'Buscando tus gastos de vuelos de agosto' or 'Sumando los cargos para darte el total'. Never mention tool names, ids, refs or technical terms, never include amounts or personal data, and do not promise a result. Leave it out when your actions only deliver the final answer.",
|
|
20
21
|
"NEVER_EMPTY: 'actions' always has at least one action. 'reasoning' and 'state' are never shown to the user, so writing there that you will answer or summarize delivers nothing. As soon as you have what you need, your action is 'respond' with the complete final answer, written in that same response.",
|
|
21
22
|
`LOOP: After your actions run, the next message you receive is {"OBSERVATIONS": [...]} with one entry per action (ref, tool, status, output or error). Continue from there. You finish the task only with a 'respond' action, which delivers your final answer; use it alone or with actions whose results you no longer need.`,
|
|
22
23
|
"HARNESS_NOTICES: A message may contain a 'HARNESS' key with notices from your body, such as the remaining budget, a warning, a stop reason, 'known' (the facts kept for you, including the answers of the user) or 'schemas' (the arguments of the tools you have already seen). Obey them.",
|
|
@@ -66,7 +67,8 @@ const reasoningEngine = new Skill({
|
|
|
66
67
|
next: "string"
|
|
67
68
|
},
|
|
68
69
|
actions: [{ tool: "string", arguments: "object" }],
|
|
69
|
-
learned: [{ key: "string", value: "string" }]
|
|
70
|
+
learned: [{ key: "string", value: "string" }],
|
|
71
|
+
activity: "string"
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -25,7 +25,7 @@ var import_skill = require("../../../skills/skill.js");
|
|
|
25
25
|
var import_shared_rules = require("../../../skills/shared/shared-rules.js");
|
|
26
26
|
const fastResponder = new import_skill.Skill({
|
|
27
27
|
name: "fast_responder",
|
|
28
|
-
version: "2.
|
|
28
|
+
version: "2.4.0",
|
|
29
29
|
description: "Handles general conversations and multipurpose user assistance.",
|
|
30
30
|
temperature: 0.7,
|
|
31
31
|
systemInstructions: {
|
|
@@ -41,6 +41,7 @@ const fastResponder = new import_skill.Skill({
|
|
|
41
41
|
"LANGUAGE_DETECTION: Identify the language of the CURRENT user message in INPUT.user_message, or follow any explicit request to answer in a specific language (e.g., 'responde en espa\xF1ol', 'reply in English'). Base this decision ONLY on the actual text the user just typed. CONTEXT.user_details.preferred_language reflects the app's configured display language, NOT what the user is typing right now \u2014 it MUST NEVER influence this detection, even when it disagrees with the message's actual language. Always generate the 'answer' field in that detected or requested language, and set 'detected_language' in the output to its 2-letter ISO 639-1 code (e.g., 'es', 'en', 'fr').",
|
|
42
42
|
"MEMORY_AND_PERSONAL_DATA_CHECK: Do NOT assume, pretend, or hallucinate remembering past events, meetings, notes, or specific user context. If the user asks about something mentioned in the past (e.g., 'recuerdas la reuni\xF3n...?', 'qu\xE9 te dije de...?'), set 'can_answer' to false UNLESS the exact details are explicitly provided inside 'context_injection'. Never fake memory.",
|
|
43
43
|
"CAPABILITY_CHECK: Set 'can_answer' to false if: 1) The query involves creating, registering, updating, or deleting data or non-text resources (e.g., expenses, records, reminders, calendar entries), 2) The query refers to personal memory, past events, meetings, or stored notes not present in 'context_injection', 3) The query requires specialized skills or tools (e.g., searching databases, calendar lookup, external integrations), 4) The query requires live internet access (news, weather, live data), 5) The query is a correction, rejection, or negative feedback regarding a previously executed task or tool response (e.g., 'no era esa fecha', 'te equivocaste', 'busca otra opci\xF3n', 'eso no sirvi\xF3'). When 'can_answer' is false, leave 'answer' minimal or empty for the fallback engine.",
|
|
44
|
+
"ACTIVITY: When 'can_answer' is false, write in 'activity' one short sentence, around ten words, in 'detected_language', in plain words that say what you are going to do to help the user, for example 'Voy a buscar tus gastos de vuelos de agosto'. Never mention tool names or technical terms, never include amounts or personal data, and do not promise a result. Leave it empty when 'can_answer' is true.",
|
|
44
45
|
"REASONING: Always generate the 'reasoning' field with a short explanation in English of the decision-making process, regardless of whether 'can_answer' is true or false.",
|
|
45
46
|
import_shared_rules.FORMATTING,
|
|
46
47
|
import_shared_rules.LATEX_FORMATTING,
|
|
@@ -54,7 +55,8 @@ const fastResponder = new import_skill.Skill({
|
|
|
54
55
|
can_answer: "boolean",
|
|
55
56
|
answer: "string",
|
|
56
57
|
reasoning: "string",
|
|
57
|
-
detected_language: "string"
|
|
58
|
+
detected_language: "string",
|
|
59
|
+
activity: "string"
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
}
|
|
@@ -3,7 +3,7 @@ import { Skill } from "../../../skills/skill.js";
|
|
|
3
3
|
import { FORMATTING, LATEX_FORMATTING, CITATION_FORMATTING, POLICY_RESTRICTIONS } from "../../../skills/shared/shared-rules.js";
|
|
4
4
|
const fastResponder = new Skill({
|
|
5
5
|
name: "fast_responder",
|
|
6
|
-
version: "2.
|
|
6
|
+
version: "2.4.0",
|
|
7
7
|
description: "Handles general conversations and multipurpose user assistance.",
|
|
8
8
|
temperature: 0.7,
|
|
9
9
|
systemInstructions: {
|
|
@@ -19,6 +19,7 @@ const fastResponder = new Skill({
|
|
|
19
19
|
"LANGUAGE_DETECTION: Identify the language of the CURRENT user message in INPUT.user_message, or follow any explicit request to answer in a specific language (e.g., 'responde en espa\xF1ol', 'reply in English'). Base this decision ONLY on the actual text the user just typed. CONTEXT.user_details.preferred_language reflects the app's configured display language, NOT what the user is typing right now \u2014 it MUST NEVER influence this detection, even when it disagrees with the message's actual language. Always generate the 'answer' field in that detected or requested language, and set 'detected_language' in the output to its 2-letter ISO 639-1 code (e.g., 'es', 'en', 'fr').",
|
|
20
20
|
"MEMORY_AND_PERSONAL_DATA_CHECK: Do NOT assume, pretend, or hallucinate remembering past events, meetings, notes, or specific user context. If the user asks about something mentioned in the past (e.g., 'recuerdas la reuni\xF3n...?', 'qu\xE9 te dije de...?'), set 'can_answer' to false UNLESS the exact details are explicitly provided inside 'context_injection'. Never fake memory.",
|
|
21
21
|
"CAPABILITY_CHECK: Set 'can_answer' to false if: 1) The query involves creating, registering, updating, or deleting data or non-text resources (e.g., expenses, records, reminders, calendar entries), 2) The query refers to personal memory, past events, meetings, or stored notes not present in 'context_injection', 3) The query requires specialized skills or tools (e.g., searching databases, calendar lookup, external integrations), 4) The query requires live internet access (news, weather, live data), 5) The query is a correction, rejection, or negative feedback regarding a previously executed task or tool response (e.g., 'no era esa fecha', 'te equivocaste', 'busca otra opci\xF3n', 'eso no sirvi\xF3'). When 'can_answer' is false, leave 'answer' minimal or empty for the fallback engine.",
|
|
22
|
+
"ACTIVITY: When 'can_answer' is false, write in 'activity' one short sentence, around ten words, in 'detected_language', in plain words that say what you are going to do to help the user, for example 'Voy a buscar tus gastos de vuelos de agosto'. Never mention tool names or technical terms, never include amounts or personal data, and do not promise a result. Leave it empty when 'can_answer' is true.",
|
|
22
23
|
"REASONING: Always generate the 'reasoning' field with a short explanation in English of the decision-making process, regardless of whether 'can_answer' is true or false.",
|
|
23
24
|
FORMATTING,
|
|
24
25
|
LATEX_FORMATTING,
|
|
@@ -32,7 +33,8 @@ const fastResponder = new Skill({
|
|
|
32
33
|
can_answer: "boolean",
|
|
33
34
|
answer: "string",
|
|
34
35
|
reasoning: "string",
|
|
35
|
-
detected_language: "string"
|
|
36
|
+
detected_language: "string",
|
|
37
|
+
activity: "string"
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -45,6 +45,7 @@ export interface TurnMeta {
|
|
|
45
45
|
export interface TurnRecord extends TurnMeta {
|
|
46
46
|
turn: number;
|
|
47
47
|
reasoning?: string;
|
|
48
|
+
activity?: string;
|
|
48
49
|
state?: Record<string, any>;
|
|
49
50
|
}
|
|
50
51
|
export interface ActionRequest {
|
|
@@ -53,6 +54,7 @@ export interface ActionRequest {
|
|
|
53
54
|
}
|
|
54
55
|
export interface TurnOutput {
|
|
55
56
|
reasoning?: string;
|
|
57
|
+
activity?: string;
|
|
56
58
|
state?: Record<string, any>;
|
|
57
59
|
actions?: ActionRequest[];
|
|
58
60
|
learned?: {
|
|
@@ -427,7 +427,7 @@ class AgentTask extends import_base.BaseEntity {
|
|
|
427
427
|
addTurn(output, opts) {
|
|
428
428
|
const turn = this.turns.reduce((max, t) => Math.max(max, t.turn), 0) + 1;
|
|
429
429
|
this.remember(output.learned);
|
|
430
|
-
this.turns.push({ turn, reasoning: output.reasoning?.toString().trim().slice(0, REASONING_CHARS) || void 0, state: capState(output.state), ...definedOnly(opts?.meta) });
|
|
430
|
+
this.turns.push({ turn, reasoning: output.reasoning?.toString().trim().slice(0, REASONING_CHARS) || void 0, ...output.activity ? { activity: output.activity } : {}, state: capState(output.state), ...definedOnly(opts?.meta) });
|
|
431
431
|
const requests = Array.isArray(output.actions) ? output.actions : [];
|
|
432
432
|
if (!requests.length) {
|
|
433
433
|
const action = this.addAction({ name: INVALID_RESPONSE, args: {}, stepId: `${turn}_1`, turn, author: opts?.author });
|
|
@@ -393,7 +393,7 @@ class AgentTask extends BaseEntity {
|
|
|
393
393
|
addTurn(output, opts) {
|
|
394
394
|
const turn = this.turns.reduce((max, t) => Math.max(max, t.turn), 0) + 1;
|
|
395
395
|
this.remember(output.learned);
|
|
396
|
-
this.turns.push({ turn, reasoning: output.reasoning?.toString().trim().slice(0, REASONING_CHARS) || void 0, state: capState(output.state), ...definedOnly(opts?.meta) });
|
|
396
|
+
this.turns.push({ turn, reasoning: output.reasoning?.toString().trim().slice(0, REASONING_CHARS) || void 0, ...output.activity ? { activity: output.activity } : {}, state: capState(output.state), ...definedOnly(opts?.meta) });
|
|
397
397
|
const requests = Array.isArray(output.actions) ? output.actions : [];
|
|
398
398
|
if (!requests.length) {
|
|
399
399
|
const action = this.addAction({ name: INVALID_RESPONSE, args: {}, stepId: `${turn}_1`, turn, author: opts?.author });
|
package/docs/agent.md
CHANGED
|
@@ -198,7 +198,7 @@ await agent.run({ input: { chatId, message }, currentUser })
|
|
|
198
198
|
stop()
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
-
The listener receives every change of `state.currentActivity` while the run is in progress,
|
|
201
|
+
The listener receives every change of `state.currentActivity` while the run is in progress, and a last `stopped` when the run ends. It does not receive a value that repeats the previous one. With `AgiLoop` the value is a short sentence written by the model in the language of the conversation, such as `Buscando tus gastos de vuelos de agosto`, shown from the answer that asked for the actions until the next answer. When the model gives none, the generic ones appear: `Starting...`, `Analyzing requirement...`, `Thinking...` or `Running search...`. See [loops](loops.md#agiloop).
|
|
202
202
|
|
|
203
203
|
- The listener belongs to that `Agent` instance and to the chat of its current run. Nothing is shared between instances, so concurrent runs in the same process, even of different users, never hear each other. As always, create one `Agent` per run and do not share it between concurrent requests.
|
|
204
204
|
- It is called synchronously from the loop, so keep it fast and do not await inside it. An error thrown by a listener is logged and ignored, the run goes on and the other listeners still run.
|
package/docs/loops.md
CHANGED
|
@@ -13,10 +13,12 @@ import { AgiLoop } from 'openloops/loops'
|
|
|
13
13
|
|
|
14
14
|
| Node | What it does |
|
|
15
15
|
| --- | --- |
|
|
16
|
-
| `fast_responder` | Initial node. Answers directly when no tools or memory are needed. It is skipped in an autonomous run. |
|
|
17
|
-
| `reasoning_engine` | Reads the situation or the results of the last actions, rewrites its working state, decides the next actions
|
|
16
|
+
| `fast_responder` | Initial node. Answers directly when no tools or memory are needed, and when it cannot, says in one sentence what the agent will do. It is skipped in an autonomous run. |
|
|
17
|
+
| `reasoning_engine` | Reads the situation or the results of the last actions, rewrites its working state, decides the next actions, reports the language of the conversation and says in one sentence what is happening until its next answer. |
|
|
18
18
|
| `action_engine` | Runs the actions the reasoning engine asked for, asks the user for confirmation when needed, delivers the final answer. |
|
|
19
19
|
|
|
20
|
+
The sentences of both nodes become `state.currentActivity`, written in the language of the conversation, so a client can show what the agent is doing instead of a generic `Thinking...`. They are optional: when a node leaves it out or writes something unusable (not a text, empty, `running`, `stopped`), the loop shows the generic activity of that moment. The text is cleaned of markup and line breaks and cut at 80 characters, and each one is kept in the turn that produced it (`turns[].activity`) to audit what the user saw.
|
|
21
|
+
|
|
20
22
|
The loop works within a budget per task (20 reasoning turns and 40 tool calls) and stops with an honest answer when the model repeats itself, keeps only reading notes, or runs out of budget. It also rejects final answers that cite identifiers that never appeared in a result or in the user's words.
|
|
21
23
|
|
|
22
24
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openloops",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Open source harness for AI agents: a TypeScript runtime with persistence, tools, MCP trust, approvals and autonomous jobs, where the loop is pluggable",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jose Barcos",
|