openloops 0.2.8 → 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.
@@ -12,6 +12,7 @@ export interface AgentError {
12
12
  timestamp: Date;
13
13
  }
14
14
  type CurrentActivity = 'running' | 'stopped' | (string & {});
15
+ export type ActivityListener = (activity: string) => void;
15
16
  export interface AgentStateProps {
16
17
  status?: AgentStatus;
17
18
  language?: string;
@@ -27,11 +28,15 @@ export declare class AgentState {
27
28
  activeTaskId?: string | undefined;
28
29
  stopRequested?: boolean | undefined;
29
30
  currentActivity?: CurrentActivity | undefined;
31
+ private activityListener?;
32
+ private activityFromModel;
30
33
  static fromJSON(props?: AgentStateProps): AgentState;
31
34
  constructor(status?: AgentStatus | undefined, language?: string | undefined, lastError?: AgentError | undefined, activeTaskId?: string | undefined, stopRequested?: boolean | undefined, currentActivity?: CurrentActivity | undefined);
32
35
  toJSON(): AgentStateProps;
33
36
  setLanguage(language?: string): void;
34
- setCurrentActivity(currentActivity: CurrentActivity): void;
37
+ onActivityChange(listener?: ActivityListener): void;
38
+ get hasModelActivity(): boolean;
39
+ setCurrentActivity(currentActivity: CurrentActivity, source?: 'system' | 'model'): void;
35
40
  setStatus(status: AgentStatus): void;
36
41
  setActiveTaskId(taskId?: string): void;
37
42
  setLastError(lastError?: AgentError): void;
@@ -45,6 +45,8 @@ class AgentState {
45
45
  activeTaskId;
46
46
  stopRequested;
47
47
  currentActivity;
48
+ activityListener;
49
+ activityFromModel = false;
48
50
  static fromJSON(props = {}) {
49
51
  return new AgentState(
50
52
  props.status,
@@ -68,8 +70,17 @@ class AgentState {
68
70
  setLanguage(language) {
69
71
  if (language) this.language = language;
70
72
  }
71
- setCurrentActivity(currentActivity) {
73
+ onActivityChange(listener) {
74
+ this.activityListener = listener;
75
+ }
76
+ get hasModelActivity() {
77
+ return this.activityFromModel;
78
+ }
79
+ setCurrentActivity(currentActivity, source = "system") {
80
+ const changed = this.currentActivity !== currentActivity;
72
81
  this.currentActivity = currentActivity;
82
+ this.activityFromModel = source === "model";
83
+ if (changed) this.activityListener?.(currentActivity);
73
84
  }
74
85
  setStatus(status) {
75
86
  this.status = status;
@@ -22,6 +22,8 @@ class AgentState {
22
22
  activeTaskId;
23
23
  stopRequested;
24
24
  currentActivity;
25
+ activityListener;
26
+ activityFromModel = false;
25
27
  static fromJSON(props = {}) {
26
28
  return new AgentState(
27
29
  props.status,
@@ -45,8 +47,17 @@ class AgentState {
45
47
  setLanguage(language) {
46
48
  if (language) this.language = language;
47
49
  }
48
- setCurrentActivity(currentActivity) {
50
+ onActivityChange(listener) {
51
+ this.activityListener = listener;
52
+ }
53
+ get hasModelActivity() {
54
+ return this.activityFromModel;
55
+ }
56
+ setCurrentActivity(currentActivity, source = "system") {
57
+ const changed = this.currentActivity !== currentActivity;
49
58
  this.currentActivity = currentActivity;
59
+ this.activityFromModel = source === "model";
60
+ if (changed) this.activityListener?.(currentActivity);
50
61
  }
51
62
  setStatus(status) {
52
63
  this.status = status;
@@ -6,6 +6,7 @@ import { ChatSettingsProps } from '../services/chats/entities/chat-settings.enti
6
6
  import { Tool } from '../tools/tool.js';
7
7
  import { Guard } from '../guardrails/guard.js';
8
8
  import { AgentLoop } from './agent-loop';
9
+ import { ActivityListener } from './agent-state';
9
10
  export interface InternalMcp {
10
11
  name: string;
11
12
  url: string;
@@ -58,6 +59,7 @@ export declare class Agent {
58
59
  private mcpListingFailed;
59
60
  private _preHooks;
60
61
  private _postHooks;
62
+ private _activityListeners;
61
63
  private _guards;
62
64
  private awaitingConfirmation;
63
65
  private currentChat;
@@ -101,6 +103,8 @@ export declare class Agent {
101
103
  addTool(tool: Tool): void;
102
104
  addInternalMcp(mcp: InternalMcp): void;
103
105
  addHook(type: HookType, fn: Function): void;
106
+ onActivity(listener: ActivityListener): () => void;
107
+ private emitActivity;
104
108
  addGuard(guard: Guard): void;
105
109
  private preRunner;
106
110
  private runInputGuards;
@@ -76,6 +76,7 @@ class Agent {
76
76
  mcpListingFailed = false;
77
77
  _preHooks = [];
78
78
  _postHooks = [];
79
+ _activityListeners = [];
79
80
  _guards = [];
80
81
  awaitingConfirmation = false;
81
82
  currentChat;
@@ -206,6 +207,21 @@ class Agent {
206
207
  if (type === "pre_execution") this._preHooks.push(fn);
207
208
  if (type === "post_execution") this._postHooks.push(fn);
208
209
  }
210
+ onActivity(listener) {
211
+ this._activityListeners.push(listener);
212
+ return () => {
213
+ this._activityListeners = this._activityListeners.filter((candidate) => candidate !== listener);
214
+ };
215
+ }
216
+ emitActivity(activity) {
217
+ for (const listener of this._activityListeners) {
218
+ try {
219
+ listener(activity);
220
+ } catch (error) {
221
+ this.logger.warn({ error: error?.message ?? error }, "[AGENT] An activity listener failed");
222
+ }
223
+ }
224
+ }
209
225
  addGuard(guard) {
210
226
  this._guards.push(guard);
211
227
  }
@@ -227,6 +243,7 @@ class Agent {
227
243
  this.currentChat.switchLoop(this._loop.name);
228
244
  await this.loadTasks();
229
245
  }
246
+ this.currentChat.state?.onActivityChange((activity) => this.emitActivity(activity));
230
247
  const userMessage = this.currentChat.pushMessage({
231
248
  role: "user",
232
249
  content: this.currentMessage,
@@ -61,6 +61,7 @@ class Agent {
61
61
  mcpListingFailed = false;
62
62
  _preHooks = [];
63
63
  _postHooks = [];
64
+ _activityListeners = [];
64
65
  _guards = [];
65
66
  awaitingConfirmation = false;
66
67
  currentChat;
@@ -191,6 +192,21 @@ class Agent {
191
192
  if (type === "pre_execution") this._preHooks.push(fn);
192
193
  if (type === "post_execution") this._postHooks.push(fn);
193
194
  }
195
+ onActivity(listener) {
196
+ this._activityListeners.push(listener);
197
+ return () => {
198
+ this._activityListeners = this._activityListeners.filter((candidate) => candidate !== listener);
199
+ };
200
+ }
201
+ emitActivity(activity) {
202
+ for (const listener of this._activityListeners) {
203
+ try {
204
+ listener(activity);
205
+ } catch (error) {
206
+ this.logger.warn({ error: error?.message ?? error }, "[AGENT] An activity listener failed");
207
+ }
208
+ }
209
+ }
194
210
  addGuard(guard) {
195
211
  this._guards.push(guard);
196
212
  }
@@ -212,6 +228,7 @@ class Agent {
212
228
  this.currentChat.switchLoop(this._loop.name);
213
229
  await this.loadTasks();
214
230
  }
231
+ this.currentChat.state?.onActivityChange((activity) => this.emitActivity(activity));
215
232
  const userMessage = this.currentChat.pushMessage({
216
233
  role: "user",
217
234
  content: this.currentMessage,
@@ -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
+ };
@@ -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.7.0";
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
- task.addTurn(result, {
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) {
@@ -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.7.0";
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
- task.addTurn(result, {
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) {
@@ -11,5 +11,6 @@ export type ResponseSchema = {
11
11
  key: string;
12
12
  value: string;
13
13
  }[];
14
+ activity?: string;
14
15
  };
15
16
  export declare const reasoningEngine: Skill<ResponseSchema>;
@@ -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.4.0",
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.4.0",
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
  }
@@ -4,6 +4,7 @@ type ResponseSchema = {
4
4
  answer: string;
5
5
  reasoning: string;
6
6
  detected_language: string;
7
+ activity?: string;
7
8
  };
8
9
  export declare const fastResponder: Skill<ResponseSchema>;
9
10
  export {};
@@ -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.3.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.3.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
@@ -186,6 +186,25 @@ agent.addHook('post_execution', async () => {
186
186
 
187
187
  Hooks do not run when a guard blocks the message, because the loop never starts.
188
188
 
189
+ ## Activity updates
190
+
191
+ ```typescript
192
+ const stop = agent.onActivity(activity => {
193
+ stream.write(`event: activity\ndata: ${JSON.stringify({ activity })}\n\n`)
194
+ })
195
+
196
+ await agent.run({ input: { chatId, message }, currentUser })
197
+
198
+ stop()
199
+ ```
200
+
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
+
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
+ - 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.
205
+ - `onActivity` returns a function that removes the listener.
206
+ - Past values are not replayed. If a client connects late or loses its connection, read `state.currentActivity` of the chat, which is saved with it.
207
+
189
208
  ## Stopping a running turn
190
209
 
191
210
  ```typescript
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 and reports the language of the conversation. |
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.8",
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",