openloops 0.2.9 → 0.3.0

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.
Files changed (35) hide show
  1. package/dist/clients/llm/llm-client.js +4 -2
  2. package/dist/clients/llm/llm-client.mjs +4 -2
  3. package/dist/clients/llm/llm-types.d.ts +2 -0
  4. package/dist/harness/agent-state.d.ts +3 -1
  5. package/dist/harness/agent-state.js +7 -4
  6. package/dist/harness/agent-state.mjs +7 -4
  7. package/dist/harness/agent.js +13 -12
  8. package/dist/harness/agent.mjs +13 -12
  9. package/dist/harness/utils/activity.d.ts +1 -0
  10. package/dist/harness/utils/activity.js +37 -0
  11. package/dist/harness/utils/activity.mjs +14 -0
  12. package/dist/loops/agi/loop.js +10 -4
  13. package/dist/loops/agi/loop.mjs +10 -4
  14. package/dist/loops/agi/skills/reasoning-engine.d.ts +1 -0
  15. package/dist/loops/agi/skills/reasoning-engine.js +4 -2
  16. package/dist/loops/agi/skills/reasoning-engine.mjs +4 -2
  17. package/dist/loops/shared/skills/fast-responder.d.ts +1 -0
  18. package/dist/loops/shared/skills/fast-responder.js +5 -2
  19. package/dist/loops/shared/skills/fast-responder.mjs +5 -2
  20. package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +3 -0
  21. package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +3 -0
  22. package/dist/services/chats/utils/deprecated-activity.d.ts +1 -0
  23. package/dist/services/chats/utils/deprecated-activity.js +60 -0
  24. package/dist/services/chats/utils/deprecated-activity.mjs +37 -0
  25. package/dist/services/tasks/entities/agent-task.entity.d.ts +2 -0
  26. package/dist/services/tasks/entities/agent-task.entity.js +1 -1
  27. package/dist/services/tasks/entities/agent-task.entity.mjs +1 -1
  28. package/dist/skills/skill.d.ts +3 -1
  29. package/dist/skills/skill.js +4 -1
  30. package/dist/skills/skill.mjs +4 -1
  31. package/docs/agent.md +3 -2
  32. package/docs/chats.md +7 -1
  33. package/docs/loops.md +4 -2
  34. package/docs/skills.md +1 -0
  35. package/package.json +1 -1
@@ -87,7 +87,8 @@ class LLMClient {
87
87
  messages,
88
88
  tools,
89
89
  toolChoice,
90
- temperature = DEFAULT_TEMPERATURE
90
+ temperature = DEFAULT_TEMPERATURE,
91
+ thinking
91
92
  } = params;
92
93
  const { provider, model: modelName } = this.chooseModel(params);
93
94
  const { builtinModels } = await import("@earendil-works/pi-ai/providers/all");
@@ -99,7 +100,8 @@ class LLMClient {
99
100
  const context = (0, import_pi_ai_adapter.toPiContext)({ messages, tools }, model);
100
101
  const send = (omitTemperature) => this.withDeadline((signal) => {
101
102
  const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
102
- return resolvedChoice ? models.completeSimple(model, context, { ...options, toolChoice: resolvedChoice }) : models.complete(model, context, options);
103
+ const reasoning = thinking && thinking !== "off" ? thinking : void 0;
104
+ return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
103
105
  });
104
106
  const raw = await this.traced(
105
107
  { origin, sessionId, answerId, currentUser, modelName, provider, temperature },
@@ -55,7 +55,8 @@ class LLMClient {
55
55
  messages,
56
56
  tools,
57
57
  toolChoice,
58
- temperature = DEFAULT_TEMPERATURE
58
+ temperature = DEFAULT_TEMPERATURE,
59
+ thinking
59
60
  } = params;
60
61
  const { provider, model: modelName } = this.chooseModel(params);
61
62
  const { builtinModels } = await import("@earendil-works/pi-ai/providers/all");
@@ -67,7 +68,8 @@ class LLMClient {
67
68
  const context = toPiContext({ messages, tools }, model);
68
69
  const send = (omitTemperature) => this.withDeadline((signal) => {
69
70
  const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
70
- return resolvedChoice ? models.completeSimple(model, context, { ...options, toolChoice: resolvedChoice }) : models.complete(model, context, options);
71
+ const reasoning = thinking && thinking !== "off" ? thinking : void 0;
72
+ return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
71
73
  });
72
74
  const raw = await this.traced(
73
75
  { origin, sessionId, answerId, currentUser, modelName, provider, temperature },
@@ -50,6 +50,7 @@ export interface LLMResponse {
50
50
  native?: unknown;
51
51
  }
52
52
  export type LLMToolChoice = 'auto' | 'none' | 'required';
53
+ export type ThinkingEffort = 'off' | 'low' | 'medium' | 'high';
53
54
  export interface LLMChatParams {
54
55
  origin: string;
55
56
  sessionId: string;
@@ -61,4 +62,5 @@ export interface LLMChatParams {
61
62
  provider?: string;
62
63
  modelName?: string;
63
64
  temperature?: number;
65
+ thinking?: ThinkingEffort;
64
66
  }
@@ -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
- setCurrentActivity(currentActivity: CurrentActivity): void;
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,19 +46,18 @@ 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,
52
53
  props.language,
53
54
  props.lastError,
54
55
  props.activeTaskId,
55
- props.stopRequested,
56
- props.currentActivity
56
+ props.stopRequested
57
57
  );
58
58
  }
59
59
  toJSON() {
60
60
  return {
61
- currentActivity: this.currentActivity,
62
61
  language: this.language,
63
62
  status: this.status,
64
63
  activeTaskId: this.activeTaskId,
@@ -72,9 +71,13 @@ class AgentState {
72
71
  onActivityChange(listener) {
73
72
  this.activityListener = listener;
74
73
  }
75
- setCurrentActivity(currentActivity) {
74
+ get hasModelActivity() {
75
+ return this.activityFromModel;
76
+ }
77
+ setCurrentActivity(currentActivity, source = "system") {
76
78
  const changed = this.currentActivity !== currentActivity;
77
79
  this.currentActivity = currentActivity;
80
+ this.activityFromModel = source === "model";
78
81
  if (changed) this.activityListener?.(currentActivity);
79
82
  }
80
83
  setStatus(status) {
@@ -23,19 +23,18 @@ 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,
29
30
  props.language,
30
31
  props.lastError,
31
32
  props.activeTaskId,
32
- props.stopRequested,
33
- props.currentActivity
33
+ props.stopRequested
34
34
  );
35
35
  }
36
36
  toJSON() {
37
37
  return {
38
- currentActivity: this.currentActivity,
39
38
  language: this.language,
40
39
  status: this.status,
41
40
  activeTaskId: this.activeTaskId,
@@ -49,9 +48,13 @@ class AgentState {
49
48
  onActivityChange(listener) {
50
49
  this.activityListener = listener;
51
50
  }
52
- setCurrentActivity(currentActivity) {
51
+ get hasModelActivity() {
52
+ return this.activityFromModel;
53
+ }
54
+ setCurrentActivity(currentActivity, source = "system") {
53
55
  const changed = this.currentActivity !== currentActivity;
54
56
  this.currentActivity = currentActivity;
57
+ this.activityFromModel = source === "model";
55
58
  if (changed) this.activityListener?.(currentActivity);
56
59
  }
57
60
  setStatus(status) {
@@ -717,18 +717,19 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
717
717
  }));
718
718
  }
719
719
  async saveChat(props) {
720
- if (this.currentChat?._id) {
721
- this.logger.debug("[AGENT] Updating chat...");
722
- if (!props?.resetStop) {
723
- this.logger.debug("[Agent] Removing stopRequested");
724
- delete this.currentChat.state?.stopRequested;
725
- }
726
- await (0, import_chats.updateChat)({
727
- id: this.currentChat._id.toString(),
728
- payload: this.currentChat.toJSON(),
729
- currentUser: this.currentUser
730
- });
731
- }
720
+ if (!this.currentChat?._id) return;
721
+ if (!props?.resetStop) {
722
+ this.logger.debug("[Agent] Removing stopRequested");
723
+ delete this.currentChat.state?.stopRequested;
724
+ }
725
+ const id = this.currentChat._id.toString();
726
+ const payload = this.currentChat.toJSON();
727
+ const key = `chat:${id}`;
728
+ const current = JSON.stringify(payload);
729
+ if (this.snapshots.get(key) === current) return;
730
+ this.logger.debug("[AGENT] Updating chat...");
731
+ await (0, import_chats.updateChat)({ id, payload, currentUser: this.currentUser });
732
+ this.snapshots.set(key, current);
732
733
  }
733
734
  async checkInterruptionRequest() {
734
735
  const chatId = this.currentChat?._id?.toString();
@@ -702,18 +702,19 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
702
702
  }));
703
703
  }
704
704
  async saveChat(props) {
705
- if (this.currentChat?._id) {
706
- this.logger.debug("[AGENT] Updating chat...");
707
- if (!props?.resetStop) {
708
- this.logger.debug("[Agent] Removing stopRequested");
709
- delete this.currentChat.state?.stopRequested;
710
- }
711
- await updateChat({
712
- id: this.currentChat._id.toString(),
713
- payload: this.currentChat.toJSON(),
714
- currentUser: this.currentUser
715
- });
716
- }
705
+ if (!this.currentChat?._id) return;
706
+ if (!props?.resetStop) {
707
+ this.logger.debug("[Agent] Removing stopRequested");
708
+ delete this.currentChat.state?.stopRequested;
709
+ }
710
+ const id = this.currentChat._id.toString();
711
+ const payload = this.currentChat.toJSON();
712
+ const key = `chat:${id}`;
713
+ const current = JSON.stringify(payload);
714
+ if (this.snapshots.get(key) === current) return;
715
+ this.logger.debug("[AGENT] Updating chat...");
716
+ await updateChat({ id, payload, currentUser: this.currentUser });
717
+ this.snapshots.set(key, current);
717
718
  }
718
719
  async checkInterruptionRequest() {
719
720
  const chatId = this.currentChat?._id?.toString();
@@ -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,9 +25,10 @@ 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
+ thinking: "low",
31
32
  systemInstructions: {
32
33
  instruction_set: {
33
34
  goal: "Provide general assistance in a friendly, empathetic, and natural manner as a close companion.",
@@ -41,6 +42,7 @@ const fastResponder = new import_skill.Skill({
41
42
  "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
43
  "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
44
  "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.",
45
+ "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
46
  "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
47
  import_shared_rules.FORMATTING,
46
48
  import_shared_rules.LATEX_FORMATTING,
@@ -54,7 +56,8 @@ const fastResponder = new import_skill.Skill({
54
56
  can_answer: "boolean",
55
57
  answer: "string",
56
58
  reasoning: "string",
57
- detected_language: "string"
59
+ detected_language: "string",
60
+ activity: "string"
58
61
  }
59
62
  }
60
63
  }
@@ -3,9 +3,10 @@ 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
+ thinking: "low",
9
10
  systemInstructions: {
10
11
  instruction_set: {
11
12
  goal: "Provide general assistance in a friendly, empathetic, and natural manner as a close companion.",
@@ -19,6 +20,7 @@ const fastResponder = new Skill({
19
20
  "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
21
  "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
22
  "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.",
23
+ "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
24
  "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
25
  FORMATTING,
24
26
  LATEX_FORMATTING,
@@ -32,7 +34,8 @@ const fastResponder = new Skill({
32
34
  can_answer: "boolean",
33
35
  answer: "string",
34
36
  reasoning: "string",
35
- detected_language: "string"
37
+ detected_language: "string",
38
+ activity: "string"
36
39
  }
37
40
  }
38
41
  }
@@ -33,6 +33,8 @@ module.exports = __toCommonJS(get_chat_by_id_use_case_exports);
33
33
  var import_tsyringe = require("tsyringe");
34
34
  var import_base = require("../../../common/base/base.use-case.js");
35
35
  var import_repositories2 = require("../repositories");
36
+ var import_agent_state = require("../../../harness/agent-state.js");
37
+ var import_deprecated_activity = require("../utils/deprecated-activity");
36
38
  let GetChatByIdUseCase = class extends import_base.BaseUseCase {
37
39
  constructor(chatRepository) {
38
40
  super();
@@ -42,6 +44,7 @@ let GetChatByIdUseCase = class extends import_base.BaseUseCase {
42
44
  async execute(params) {
43
45
  const { id, select } = params;
44
46
  const data = await this.chatRepository?.findById(id, select) || {};
47
+ if (data.state?.status === import_agent_state.AgentStatus.PROCESSING) data.state.currentActivity = (0, import_deprecated_activity.deprecatedActivity)(id);
45
48
  return { data };
46
49
  }
47
50
  };
@@ -5,6 +5,8 @@ import {
5
5
  import { autoInjectable, inject } from "tsyringe";
6
6
  import { BaseUseCase } from "../../../common/base/base.use-case.js";
7
7
  import { ChatRepository } from "../repositories";
8
+ import { AgentStatus } from "../../../harness/agent-state.js";
9
+ import { deprecatedActivity } from "../utils/deprecated-activity";
8
10
  let GetChatByIdUseCase = class extends BaseUseCase {
9
11
  constructor(chatRepository) {
10
12
  super();
@@ -14,6 +16,7 @@ let GetChatByIdUseCase = class extends BaseUseCase {
14
16
  async execute(params) {
15
17
  const { id, select } = params;
16
18
  const data = await this.chatRepository?.findById(id, select) || {};
19
+ if (data.state?.status === AgentStatus.PROCESSING) data.state.currentActivity = deprecatedActivity(id);
17
20
  return { data };
18
21
  }
19
22
  };
@@ -0,0 +1 @@
1
+ export declare function deprecatedActivity(chatId: string, now?: number): string;
@@ -0,0 +1,60 @@
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 deprecated_activity_exports = {};
20
+ __export(deprecated_activity_exports, {
21
+ deprecatedActivity: () => deprecatedActivity
22
+ });
23
+ module.exports = __toCommonJS(deprecated_activity_exports);
24
+ const WORDS = [
25
+ "Thinking",
26
+ "Computing",
27
+ "Pondering",
28
+ "Analyzing",
29
+ "Crunching",
30
+ "Reviewing",
31
+ "Checking",
32
+ "Working on it",
33
+ "Reasoning",
34
+ "Digging in",
35
+ "Gathering",
36
+ "Sorting",
37
+ "Calculating",
38
+ "Connecting the dots",
39
+ "Exploring",
40
+ "Piecing it together",
41
+ "Figuring it out",
42
+ "Untangling",
43
+ "Weighing options",
44
+ "Cooking"
45
+ ];
46
+ const WINDOW_IN_MS = 4e3;
47
+ function hash(text) {
48
+ let value = 5381;
49
+ for (const character of text) value = (value << 5) + value + character.charCodeAt(0) >>> 0;
50
+ return value;
51
+ }
52
+ function deprecatedActivity(chatId, now = Date.now()) {
53
+ const window = Math.floor(now / WINDOW_IN_MS);
54
+ const index = hash(`${chatId}:${window}`) % WORDS.length;
55
+ return `${WORDS[index]}...`;
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ deprecatedActivity
60
+ });
@@ -0,0 +1,37 @@
1
+ import "../../../chunk-CF3WOMB3.mjs";
2
+ const WORDS = [
3
+ "Thinking",
4
+ "Computing",
5
+ "Pondering",
6
+ "Analyzing",
7
+ "Crunching",
8
+ "Reviewing",
9
+ "Checking",
10
+ "Working on it",
11
+ "Reasoning",
12
+ "Digging in",
13
+ "Gathering",
14
+ "Sorting",
15
+ "Calculating",
16
+ "Connecting the dots",
17
+ "Exploring",
18
+ "Piecing it together",
19
+ "Figuring it out",
20
+ "Untangling",
21
+ "Weighing options",
22
+ "Cooking"
23
+ ];
24
+ const WINDOW_IN_MS = 4e3;
25
+ function hash(text) {
26
+ let value = 5381;
27
+ for (const character of text) value = (value << 5) + value + character.charCodeAt(0) >>> 0;
28
+ return value;
29
+ }
30
+ function deprecatedActivity(chatId, now = Date.now()) {
31
+ const window = Math.floor(now / WINDOW_IN_MS);
32
+ const index = hash(`${chatId}:${window}`) % WORDS.length;
33
+ return `${WORDS[index]}...`;
34
+ }
35
+ export {
36
+ deprecatedActivity
37
+ };
@@ -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 });
@@ -1,4 +1,4 @@
1
- import { LLMMessage, LLMToolDefinition } from '../clients/llm/llm-types.js';
1
+ import { LLMMessage, LLMToolDefinition, ThinkingEffort } from '../clients/llm/llm-types.js';
2
2
  import { CurrentUser, CurrentSession } from '../common/base/index.js';
3
3
  import type { Chat } from '../services/chats/entities/chat.entity.js';
4
4
  import { SkillMode } from './call-modes';
@@ -8,6 +8,7 @@ export interface SkillProps {
8
8
  version?: string;
9
9
  description?: string;
10
10
  temperature?: number;
11
+ thinking?: ThinkingEffort;
11
12
  systemInstructions: Record<string, any>;
12
13
  systemRole?: boolean;
13
14
  mode?: SkillMode;
@@ -46,6 +47,7 @@ export declare class Skill<TResponse = Record<string, any>> {
46
47
  readonly version?: string;
47
48
  readonly description?: string;
48
49
  readonly temperature?: number;
50
+ readonly thinking?: ThinkingEffort;
49
51
  readonly systemInstructions: Record<string, any>;
50
52
  readonly systemRole: boolean;
51
53
  readonly mode: SkillMode;
@@ -37,6 +37,7 @@ class Skill {
37
37
  version;
38
38
  description;
39
39
  temperature;
40
+ thinking;
40
41
  systemInstructions;
41
42
  systemRole;
42
43
  mode;
@@ -45,6 +46,7 @@ class Skill {
45
46
  this.version = props.version;
46
47
  this.description = props.description;
47
48
  this.temperature = props.temperature;
49
+ this.thinking = props.thinking;
48
50
  this.systemInstructions = props.systemInstructions;
49
51
  this.systemRole = props.systemRole ?? true;
50
52
  this.mode = props.mode ?? import_call_modes.DEFAULT_SKILL_MODE;
@@ -78,7 +80,8 @@ class Skill {
78
80
  messages: call.messages,
79
81
  tools: call.tools,
80
82
  toolChoice: call.toolChoice,
81
- temperature: this.temperature ?? 0.7
83
+ temperature: this.temperature ?? 0.7,
84
+ ...this.thinking ? { thinking: this.thinking } : {}
82
85
  });
83
86
  const reading = (0, import_call_modes.readModeResponse)(mode, this.name, response, { expectActions: Boolean(tools?.length) });
84
87
  if (reading.blocks > 1) {
@@ -13,6 +13,7 @@ class Skill {
13
13
  version;
14
14
  description;
15
15
  temperature;
16
+ thinking;
16
17
  systemInstructions;
17
18
  systemRole;
18
19
  mode;
@@ -21,6 +22,7 @@ class Skill {
21
22
  this.version = props.version;
22
23
  this.description = props.description;
23
24
  this.temperature = props.temperature;
25
+ this.thinking = props.thinking;
24
26
  this.systemInstructions = props.systemInstructions;
25
27
  this.systemRole = props.systemRole ?? true;
26
28
  this.mode = props.mode ?? DEFAULT_SKILL_MODE;
@@ -54,7 +56,8 @@ class Skill {
54
56
  messages: call.messages,
55
57
  tools: call.tools,
56
58
  toolChoice: call.toolChoice,
57
- temperature: this.temperature ?? 0.7
59
+ temperature: this.temperature ?? 0.7,
60
+ ...this.thinking ? { thinking: this.thinking } : {}
58
61
  });
59
62
  const reading = readModeResponse(mode, this.name, response, { expectActions: Boolean(tools?.length) });
60
63
  if (reading.blocks > 1) {
package/docs/agent.md CHANGED
@@ -198,12 +198,13 @@ 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, such as `Starting...`, `Thinking...` or `Running search...`, and a last `stopped` when the run ends. It does not receive a value that repeats the previous one.
201
+ The listener receives every change of the activity of the run while it is in progress, and a last `stopped` when the run ends. This is the only place where the real activity is available: since 0.3.0 it is not saved with the chat, and `state.currentActivity` is deprecated (see [chats](chats.md#statecurrentactivity-is-deprecated)). 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.
205
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.
206
+ - The activity is not saved, so it does not cost a write: the chat is saved only when something else changes, such as a message, the status or the task, and when the run ends.
207
+ - Past values are not replayed. If a client connects late or loses its connection, read the chat and use its `state.status`; a client that still reads `state.currentActivity` gets a generic word while the run is processing, and it will be removed in 0.4.0.
207
208
 
208
209
  ## Stopping a running turn
209
210
 
package/docs/chats.md CHANGED
@@ -10,10 +10,16 @@ import { createChat, getChatById, listChatsByUser, updateChat, deleteChat } from
10
10
 
11
11
  | Field | Meaning |
12
12
  | --- | --- |
13
- | `state` | `status`, detected `language`, `activeTaskId`, `currentActivity`, `lastError` and `stopRequested`. See [agent](agent.md#the-result) for the statuses. |
13
+ | `state` | `status`, detected `language`, `activeTaskId`, `lastError` and `stopRequested`. See [agent](agent.md#the-result) for the statuses. It also has `currentActivity`, which is deprecated (see below). |
14
14
  | `settings` | `modelProvider` and `modelName` (the model the chat uses, saved on every run), `loopName`, `executionMode`, `notifyOnCompletion` and `isPrivateSession`. |
15
15
  | `messages` | The conversation. Each message has `role` (`user` or `assistant`), `source`, `content`, `answerId` and `excludeFromContext`. |
16
16
 
17
+ ### `state.currentActivity` is deprecated
18
+
19
+ Since 0.3.0 the activity of a run is no longer saved with the chat, and `currentActivity` will be removed in 0.4.0. Follow a run with [`agent.onActivity`](agent.md#activity-updates), which tells every change as it happens.
20
+
21
+ For the clients that still poll the chat and read `state.currentActivity`, `getChatById` adds a generic word to it, such as `Thinking...` or `Cooking...`, only while the run is `processing`. It is one word per chat that changes every few seconds. It says nothing about what the agent is really doing, and it is not there in any other status. Move those clients to the listener before 0.4.0.
22
+
17
23
  Every assistant message of one answer shares an `answerId`. It is the id you pass as `messageId` to [usage](usage.md).
18
24
 
19
25
  `role` says on which side of the conversation a message is, and `source` says who produced it:
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 are what [`agent.onActivity`](agent.md#activity-updates) tells, 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/docs/skills.md CHANGED
@@ -44,6 +44,7 @@ export const myResponder = new Skill<ResponseSchema>({
44
44
  | `version` | no | Recorded in the metadata of every call. Bump it whenever the prompt changes. |
45
45
  | `description` | no | What the skill is for. |
46
46
  | `temperature` | no | Sampling temperature. Defaults to `0.7`. |
47
+ | `thinking` | no | How much the model thinks before it answers: `off`, `low`, `medium` or `high`. Thinking costs time and output tokens, so a skill that only classifies or answers briefly can set it low. When it is left out the provider default applies, which is high for the Claude models. The bundled `fast_responder` uses `low`. |
47
48
  | `systemRole` | no | Default `true`: the instructions travel as a system message. |
48
49
  | `mode` | no | How the model is called when tools are given. Defaults to `plain_chat`. |
49
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openloops",
3
- "version": "0.2.9",
3
+ "version": "0.3.0",
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",