openloops 0.3.3 → 0.3.5

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.
@@ -45,6 +45,7 @@ const MAX_RETRIES = 4;
45
45
  const MAX_RATE_LIMIT_WAITS = 2;
46
46
  const DEFAULT_CALL_TIMEOUT_MS = 6e4;
47
47
  const MAX_TIMEOUT_RETRIES = 2;
48
+ const HIGH_THINKING_TIMEOUT_FACTOR = 2;
48
49
  const LANGFUSE_FLUSH_TIMEOUT_MS = 5e3;
49
50
  const REQUIRED_TOOL_CHOICE = {
50
51
  "anthropic-messages": "any",
@@ -98,7 +99,7 @@ class LLMClient {
98
99
  const resolvedChoice = toolChoice === "required" ? REQUIRED_TOOL_CHOICE[model.api] : toolChoice;
99
100
  if (toolChoice === "required" && !resolvedChoice) throw new Error(`[LLM Client] forced tool choice is not supported for api ${model.api}`);
100
101
  const context = (0, import_pi_ai_adapter.toPiContext)({ messages, tools }, model);
101
- const send = (omitTemperature) => this.withDeadline((signal) => {
102
+ const send = (omitTemperature) => this.withDeadline(thinking === "high" ? this.callTimeoutMs * HIGH_THINKING_TIMEOUT_FACTOR : this.callTimeoutMs, (signal) => {
102
103
  const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
103
104
  const reasoning = thinking && thinking !== "off" ? thinking : void 0;
104
105
  return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
@@ -121,7 +122,7 @@ class LLMClient {
121
122
  user: (0, import_model_resolution.toModelRef)(currentUser?.preferences?.defaultModel)
122
123
  });
123
124
  }
124
- async withDeadline(call) {
125
+ async withDeadline(timeoutMs, call) {
125
126
  for (let attempt = 1; attempt <= MAX_TIMEOUT_RETRIES + 1; attempt++) {
126
127
  const controller = new AbortController();
127
128
  let timer;
@@ -129,15 +130,15 @@ class LLMClient {
129
130
  timer = setTimeout(() => {
130
131
  controller.abort();
131
132
  resolve(void 0);
132
- }, this.callTimeoutMs);
133
+ }, timeoutMs);
133
134
  });
134
135
  const pending = call(controller.signal);
135
136
  pending.catch(() => void 0);
136
137
  const response = await Promise.race([pending, deadline]).finally(() => clearTimeout(timer));
137
138
  if (response) return response;
138
- this.logger.warn({ attempt, timeoutMs: this.callTimeoutMs }, "[LLM Service] The model did not answer in time");
139
+ this.logger.warn({ attempt, timeoutMs }, "[LLM Service] The model did not answer in time");
139
140
  }
140
- throw new import_llm_error.LLMError("LLM_TIMEOUT", `the model did not answer within ${this.callTimeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
141
+ throw new import_llm_error.LLMError("LLM_TIMEOUT", `the model did not answer within ${timeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
141
142
  }
142
143
  async flushLangfuse() {
143
144
  if (!this.langfuseEnabled) return;
@@ -13,6 +13,7 @@ const MAX_RETRIES = 4;
13
13
  const MAX_RATE_LIMIT_WAITS = 2;
14
14
  const DEFAULT_CALL_TIMEOUT_MS = 6e4;
15
15
  const MAX_TIMEOUT_RETRIES = 2;
16
+ const HIGH_THINKING_TIMEOUT_FACTOR = 2;
16
17
  const LANGFUSE_FLUSH_TIMEOUT_MS = 5e3;
17
18
  const REQUIRED_TOOL_CHOICE = {
18
19
  "anthropic-messages": "any",
@@ -66,7 +67,7 @@ class LLMClient {
66
67
  const resolvedChoice = toolChoice === "required" ? REQUIRED_TOOL_CHOICE[model.api] : toolChoice;
67
68
  if (toolChoice === "required" && !resolvedChoice) throw new Error(`[LLM Client] forced tool choice is not supported for api ${model.api}`);
68
69
  const context = toPiContext({ messages, tools }, model);
69
- const send = (omitTemperature) => this.withDeadline((signal) => {
70
+ const send = (omitTemperature) => this.withDeadline(thinking === "high" ? this.callTimeoutMs * HIGH_THINKING_TIMEOUT_FACTOR : this.callTimeoutMs, (signal) => {
70
71
  const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
71
72
  const reasoning = thinking && thinking !== "off" ? thinking : void 0;
72
73
  return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
@@ -89,7 +90,7 @@ class LLMClient {
89
90
  user: toModelRef(currentUser?.preferences?.defaultModel)
90
91
  });
91
92
  }
92
- async withDeadline(call) {
93
+ async withDeadline(timeoutMs, call) {
93
94
  for (let attempt = 1; attempt <= MAX_TIMEOUT_RETRIES + 1; attempt++) {
94
95
  const controller = new AbortController();
95
96
  let timer;
@@ -97,15 +98,15 @@ class LLMClient {
97
98
  timer = setTimeout(() => {
98
99
  controller.abort();
99
100
  resolve(void 0);
100
- }, this.callTimeoutMs);
101
+ }, timeoutMs);
101
102
  });
102
103
  const pending = call(controller.signal);
103
104
  pending.catch(() => void 0);
104
105
  const response = await Promise.race([pending, deadline]).finally(() => clearTimeout(timer));
105
106
  if (response) return response;
106
- this.logger.warn({ attempt, timeoutMs: this.callTimeoutMs }, "[LLM Service] The model did not answer in time");
107
+ this.logger.warn({ attempt, timeoutMs }, "[LLM Service] The model did not answer in time");
107
108
  }
108
- throw new LLMError("LLM_TIMEOUT", `the model did not answer within ${this.callTimeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
109
+ throw new LLMError("LLM_TIMEOUT", `the model did not answer within ${timeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
109
110
  }
110
111
  async flushLangfuse() {
111
112
  if (!this.langfuseEnabled) return;
@@ -51,6 +51,9 @@ export interface LLMResponse {
51
51
  }
52
52
  export type LLMToolChoice = 'auto' | 'none' | 'required';
53
53
  export type ThinkingEffort = 'off' | 'low' | 'medium' | 'high';
54
+ export declare const SELECTABLE_THINKING_EFFORTS: readonly ["low", "medium", "high"];
55
+ export type SelectableThinkingEffort = typeof SELECTABLE_THINKING_EFFORTS[number];
56
+ export declare const isSelectableThinkingEffort: (value: unknown) => value is SelectableThinkingEffort;
54
57
  export interface LLMChatParams {
55
58
  origin: string;
56
59
  sessionId: string;
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
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
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -13,4 +17,15 @@ var __copyProps = (to, from, except, desc) => {
13
17
  };
14
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
19
  var llm_types_exports = {};
20
+ __export(llm_types_exports, {
21
+ SELECTABLE_THINKING_EFFORTS: () => SELECTABLE_THINKING_EFFORTS,
22
+ isSelectableThinkingEffort: () => isSelectableThinkingEffort
23
+ });
16
24
  module.exports = __toCommonJS(llm_types_exports);
25
+ const SELECTABLE_THINKING_EFFORTS = ["low", "medium", "high"];
26
+ const isSelectableThinkingEffort = (value) => SELECTABLE_THINKING_EFFORTS.includes(value);
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ SELECTABLE_THINKING_EFFORTS,
30
+ isSelectableThinkingEffort
31
+ });
@@ -0,0 +1,7 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const SELECTABLE_THINKING_EFFORTS = ["low", "medium", "high"];
3
+ const isSelectableThinkingEffort = (value) => SELECTABLE_THINKING_EFFORTS.includes(value);
4
+ export {
5
+ SELECTABLE_THINKING_EFFORTS,
6
+ isSelectableThinkingEffort
7
+ };
@@ -6,6 +6,7 @@ import { AgentTask } from '../services/tasks/entities/agent-task.entity.js';
6
6
  import { AgentAction } from '../services/tasks/entities/agent-action.entity.js';
7
7
  import { Tool, BaseParams } from '../tools/tool.js';
8
8
  import { SkillRunOptions } from '../skills/skill.js';
9
+ import { SelectableThinkingEffort } from '../clients/llm/llm-types.js';
9
10
  import { WeightedKeyword, ScoredTool } from './utils/rank-tools-by-keywords';
10
11
  import type { ToolCatalog } from './tool-catalog';
11
12
  import { Workspace } from './workspace';
@@ -15,6 +16,7 @@ export interface RunContext {
15
16
  task?: AgentTask;
16
17
  chat: Chat;
17
18
  chatOptions?: ChatSettingsProps;
19
+ thinkingEffort?: SelectableThinkingEffort;
18
20
  currentUser: CurrentUser;
19
21
  currentSession?: CurrentSession;
20
22
  currentMessage: string;
@@ -29,14 +29,12 @@ export declare class AgentState {
29
29
  stopRequested?: boolean | undefined;
30
30
  currentActivity?: CurrentActivity | undefined;
31
31
  private activityListener?;
32
- private activityFromModel;
33
32
  static fromJSON(props?: AgentStateProps): AgentState;
34
33
  constructor(status?: AgentStatus | undefined, language?: string | undefined, lastError?: AgentError | undefined, activeTaskId?: string | undefined, stopRequested?: boolean | undefined, currentActivity?: CurrentActivity | undefined);
35
34
  toJSON(): AgentStateProps;
36
35
  setLanguage(language?: string): void;
37
36
  onActivityChange(listener?: ActivityListener): void;
38
- get hasModelActivity(): boolean;
39
- setCurrentActivity(currentActivity: CurrentActivity, source?: 'system' | 'model'): void;
37
+ setCurrentActivity(currentActivity: CurrentActivity): void;
40
38
  setStatus(status: AgentStatus): void;
41
39
  setActiveTaskId(taskId?: string): void;
42
40
  setLastError(lastError?: AgentError): void;
@@ -46,7 +46,6 @@ class AgentState {
46
46
  stopRequested;
47
47
  currentActivity;
48
48
  activityListener;
49
- activityFromModel = false;
50
49
  static fromJSON(props = {}) {
51
50
  return new AgentState(
52
51
  props.status,
@@ -71,13 +70,9 @@ class AgentState {
71
70
  onActivityChange(listener) {
72
71
  this.activityListener = listener;
73
72
  }
74
- get hasModelActivity() {
75
- return this.activityFromModel;
76
- }
77
- setCurrentActivity(currentActivity, source = "system") {
73
+ setCurrentActivity(currentActivity) {
78
74
  const changed = this.currentActivity !== currentActivity;
79
75
  this.currentActivity = currentActivity;
80
- this.activityFromModel = source === "model";
81
76
  if (changed) this.activityListener?.(currentActivity);
82
77
  }
83
78
  setStatus(status) {
@@ -23,7 +23,6 @@ class AgentState {
23
23
  stopRequested;
24
24
  currentActivity;
25
25
  activityListener;
26
- activityFromModel = false;
27
26
  static fromJSON(props = {}) {
28
27
  return new AgentState(
29
28
  props.status,
@@ -48,13 +47,9 @@ class AgentState {
48
47
  onActivityChange(listener) {
49
48
  this.activityListener = listener;
50
49
  }
51
- get hasModelActivity() {
52
- return this.activityFromModel;
53
- }
54
- setCurrentActivity(currentActivity, source = "system") {
50
+ setCurrentActivity(currentActivity) {
55
51
  const changed = this.currentActivity !== currentActivity;
56
52
  this.currentActivity = currentActivity;
57
- this.activityFromModel = source === "model";
58
53
  if (changed) this.activityListener?.(currentActivity);
59
54
  }
60
55
  setStatus(status) {
@@ -50,6 +50,7 @@ export declare class Agent {
50
50
  private readonly strictMode;
51
51
  private readonly fallbackModel?;
52
52
  private model?;
53
+ private thinkingEffort?;
53
54
  private _tools;
54
55
  private _internalMcps;
55
56
  private _mcps;
@@ -45,6 +45,7 @@ var import_tool_pipeline = require("./tool-pipeline");
45
45
  var import_native_tools = require("./native-tools");
46
46
  var import_tool_catalog = require("./tool-catalog");
47
47
  var import_llm_error = require("../clients/llm/llm-error.js");
48
+ var import_llm_types = require("../clients/llm/llm-types.js");
48
49
  var import_model_resolution = require("../clients/llm/model-resolution.js");
49
50
  const MCP_CONNECT_RETRY_DELAYS_MS = [1e3, 2e3];
50
51
  const MCP_DESCRIPTION_CHARS = 300;
@@ -67,6 +68,7 @@ class Agent {
67
68
  strictMode;
68
69
  fallbackModel;
69
70
  model;
71
+ thinkingEffort;
70
72
  _tools;
71
73
  _internalMcps = [];
72
74
  _mcps = [];
@@ -173,6 +175,8 @@ class Agent {
173
175
  this.mcpTokens = mcpTokens ?? {};
174
176
  this.serviceToken = serviceToken;
175
177
  this.model = void 0;
178
+ this.thinkingEffort = void 0;
179
+ if (options?.thinkingEffort !== void 0 && !(0, import_llm_types.isSelectableThinkingEffort)(options.thinkingEffort)) throw new Error(`[AGENT] thinkingEffort must be one of ${import_llm_types.SELECTABLE_THINKING_EFFORTS.join(", ")}`);
176
180
  if (Boolean(options?.modelProvider) !== Boolean(options?.modelName)) throw new Error("[AGENT] Set both modelProvider and modelName, or neither");
177
181
  this.answerId = new import_mongodb.ObjectId().toString();
178
182
  const proceed = await this.preRunner(chatId);
@@ -260,10 +264,12 @@ class Agent {
260
264
  });
261
265
  this.currentChat.settings?.setModelProvider(this.model.provider);
262
266
  this.currentChat.settings?.setModelName(this.model.model);
267
+ if (this.chatOptions?.thinkingEffort) this.currentChat.settings?.setThinkingEffort(this.chatOptions.thinkingEffort);
268
+ const savedEffort = this.currentChat.settings?.thinkingEffort;
269
+ this.thinkingEffort = this.chatOptions?.thinkingEffort ?? ((0, import_llm_types.isSelectableThinkingEffort)(savedEffort) ? savedEffort : void 0);
263
270
  if (this.chatOptions?.loopName) this.currentChat.settings?.setLoopName(this.chatOptions.loopName);
264
271
  this.awaitingConfirmation = this.currentChat.state?.status === import_agent_state.AgentStatus.AWAITING_USER_CONFIRMATION;
265
272
  this.currentChat.state?.setStatus(import_agent_state.AgentStatus.PROCESSING);
266
- this.currentChat.state?.setCurrentActivity("Starting...");
267
273
  await this.persist({ resetStop: true });
268
274
  if (!await this.runInputGuards(userMessage)) return false;
269
275
  for (const hook of this._preHooks) {
@@ -306,7 +312,6 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
306
312
  }
307
313
  async finishBlocked() {
308
314
  this.currentChat.state?.setStatus(this.awaitingConfirmation ? import_agent_state.AgentStatus.AWAITING_USER_CONFIRMATION : import_agent_state.AgentStatus.IDLE);
309
- this.currentChat.state?.setCurrentActivity("stopped");
310
315
  await this.persist();
311
316
  await this.disconnectMcpServers();
312
317
  }
@@ -372,14 +377,12 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
372
377
  for (const hook of this._postHooks) {
373
378
  await hook();
374
379
  }
375
- this.currentChat.state?.setCurrentActivity("stopped");
376
380
  await this.persist();
377
381
  await this.disconnectMcpServers();
378
382
  }
379
383
  async failRun(message, llmError) {
380
384
  try {
381
385
  this.currentChat.state?.setStatus(import_agent_state.AgentStatus.FAILED);
382
- this.currentChat.state?.setCurrentActivity("stopped");
383
386
  this.currentChat.state?.setLastError({ code: llmError?.code ?? AGENT_ERROR_CODES.RUN_FAILED, message, isRetryable: llmError?.isRetryable ?? true, timestamp: /* @__PURE__ */ new Date() });
384
387
  this.currentChat.addTrace({ node: "agent", kind: "agent", reasoning: `Run failed: ${message}` });
385
388
  this.currentChat.failTask();
@@ -867,6 +870,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
867
870
  task: this.currentChat.activeTask,
868
871
  chat: this.currentChat,
869
872
  chatOptions: this.chatOptions,
873
+ thinkingEffort: this.thinkingEffort,
870
874
  currentUser: this.currentUser,
871
875
  currentSession: this.currentSession,
872
876
  currentMessage: this.currentMessage,
@@ -30,6 +30,7 @@ import { ToolPipeline } from "./tool-pipeline";
30
30
  import { NATIVE_TOOLS } from "./native-tools";
31
31
  import { buildToolCatalog, isDeclarable, needsSearch } from "./tool-catalog";
32
32
  import { LLMError } from "../clients/llm/llm-error.js";
33
+ import { isSelectableThinkingEffort, SELECTABLE_THINKING_EFFORTS } from "../clients/llm/llm-types.js";
33
34
  import { resolveModel, toModelRef } from "../clients/llm/model-resolution.js";
34
35
  const MCP_CONNECT_RETRY_DELAYS_MS = [1e3, 2e3];
35
36
  const MCP_DESCRIPTION_CHARS = 300;
@@ -52,6 +53,7 @@ class Agent {
52
53
  strictMode;
53
54
  fallbackModel;
54
55
  model;
56
+ thinkingEffort;
55
57
  _tools;
56
58
  _internalMcps = [];
57
59
  _mcps = [];
@@ -158,6 +160,8 @@ class Agent {
158
160
  this.mcpTokens = mcpTokens ?? {};
159
161
  this.serviceToken = serviceToken;
160
162
  this.model = void 0;
163
+ this.thinkingEffort = void 0;
164
+ if (options?.thinkingEffort !== void 0 && !isSelectableThinkingEffort(options.thinkingEffort)) throw new Error(`[AGENT] thinkingEffort must be one of ${SELECTABLE_THINKING_EFFORTS.join(", ")}`);
161
165
  if (Boolean(options?.modelProvider) !== Boolean(options?.modelName)) throw new Error("[AGENT] Set both modelProvider and modelName, or neither");
162
166
  this.answerId = new ObjectId().toString();
163
167
  const proceed = await this.preRunner(chatId);
@@ -245,10 +249,12 @@ class Agent {
245
249
  });
246
250
  this.currentChat.settings?.setModelProvider(this.model.provider);
247
251
  this.currentChat.settings?.setModelName(this.model.model);
252
+ if (this.chatOptions?.thinkingEffort) this.currentChat.settings?.setThinkingEffort(this.chatOptions.thinkingEffort);
253
+ const savedEffort = this.currentChat.settings?.thinkingEffort;
254
+ this.thinkingEffort = this.chatOptions?.thinkingEffort ?? (isSelectableThinkingEffort(savedEffort) ? savedEffort : void 0);
248
255
  if (this.chatOptions?.loopName) this.currentChat.settings?.setLoopName(this.chatOptions.loopName);
249
256
  this.awaitingConfirmation = this.currentChat.state?.status === AgentStatus.AWAITING_USER_CONFIRMATION;
250
257
  this.currentChat.state?.setStatus(AgentStatus.PROCESSING);
251
- this.currentChat.state?.setCurrentActivity("Starting...");
252
258
  await this.persist({ resetStop: true });
253
259
  if (!await this.runInputGuards(userMessage)) return false;
254
260
  for (const hook of this._preHooks) {
@@ -291,7 +297,6 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
291
297
  }
292
298
  async finishBlocked() {
293
299
  this.currentChat.state?.setStatus(this.awaitingConfirmation ? AgentStatus.AWAITING_USER_CONFIRMATION : AgentStatus.IDLE);
294
- this.currentChat.state?.setCurrentActivity("stopped");
295
300
  await this.persist();
296
301
  await this.disconnectMcpServers();
297
302
  }
@@ -357,14 +362,12 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
357
362
  for (const hook of this._postHooks) {
358
363
  await hook();
359
364
  }
360
- this.currentChat.state?.setCurrentActivity("stopped");
361
365
  await this.persist();
362
366
  await this.disconnectMcpServers();
363
367
  }
364
368
  async failRun(message, llmError) {
365
369
  try {
366
370
  this.currentChat.state?.setStatus(AgentStatus.FAILED);
367
- this.currentChat.state?.setCurrentActivity("stopped");
368
371
  this.currentChat.state?.setLastError({ code: llmError?.code ?? AGENT_ERROR_CODES.RUN_FAILED, message, isRetryable: llmError?.isRetryable ?? true, timestamp: /* @__PURE__ */ new Date() });
369
372
  this.currentChat.addTrace({ node: "agent", kind: "agent", reasoning: `Run failed: ${message}` });
370
373
  this.currentChat.failTask();
@@ -852,6 +855,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
852
855
  task: this.currentChat.activeTask,
853
856
  chat: this.currentChat,
854
857
  chatOptions: this.chatOptions,
858
+ thinkingEffort: this.thinkingEffort,
855
859
  currentUser: this.currentUser,
856
860
  currentSession: this.currentSession,
857
861
  currentMessage: this.currentMessage,
@@ -50,7 +50,7 @@ class AgiLoop extends import_harness.AgentLoop {
50
50
  return "agi";
51
51
  }
52
52
  get version() {
53
- return "1.8.1";
53
+ return "1.8.7";
54
54
  }
55
55
  get author() {
56
56
  return {
@@ -72,7 +72,6 @@ class AgiLoop extends import_harness.AgentLoop {
72
72
  harness.setNextNode(this.nodes.reasoning_engine);
73
73
  return;
74
74
  }
75
- ctx.chat.state?.setCurrentActivity("Analyzing requirement...");
76
75
  const chat_history = ctx.chat.lastHistoryMessages();
77
76
  const agentIdentity = ctx.identity;
78
77
  const result = await import_skills.fastResponder.run({
@@ -85,7 +84,7 @@ class AgiLoop extends import_harness.AgentLoop {
85
84
  ctx.chat.state?.setLanguage(result.detected_language);
86
85
  if (!result.can_answer) {
87
86
  const activity = (0, import_activity.cleanActivity)(result.activity);
88
- if (activity) ctx.chat.state?.setCurrentActivity(activity, "model");
87
+ if (activity) ctx.chat.state?.setCurrentActivity(activity);
89
88
  harness.setNextNode(this.nodes.reasoning_engine);
90
89
  } else {
91
90
  ctx.chat.state?.setStatus(import_harness.AgentStatus.IDLE);
@@ -94,7 +93,6 @@ class AgiLoop extends import_harness.AgentLoop {
94
93
  }
95
94
  }
96
95
  async reasoningEngine(ctx, harness) {
97
- if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity("Thinking...");
98
96
  const task = ctx.task ?? ctx.chat.createTask(ctx.currentMessage);
99
97
  task.answerQuestion(ctx.currentMessage);
100
98
  const streak = task.sameToolStreak;
@@ -108,6 +106,7 @@ class AgiLoop extends import_harness.AgentLoop {
108
106
  const catalog = await harness.toolCatalog();
109
107
  const result = await import_reasoning_engine.reasoningEngine.run({
110
108
  ...ctx.skillParams,
109
+ thinking: ctx.thinkingEffort,
111
110
  history: task.history({
112
111
  budget: { turns_left: MAX_TURNS - task.turnCount, tool_calls_left: MAX_TOOL_CALLS - task.toolCallCount },
113
112
  ...warning ? { warning } : {},
@@ -128,7 +127,7 @@ class AgiLoop extends import_harness.AgentLoop {
128
127
  if (/^[a-z]{2}$/.test(language)) ctx.chat.state?.setLanguage(language);
129
128
  const { rawText, ...callInfo } = result.callInfo;
130
129
  const activity = (0, import_activity.cleanActivity)(result.activity);
131
- if (activity) ctx.chat.state?.setCurrentActivity(activity, "model");
130
+ if (activity) ctx.chat.state?.setCurrentActivity(activity);
132
131
  task.addTurn({ ...result, activity }, {
133
132
  author: "reasoning_engine",
134
133
  declaredTools: catalog.tools.map((tool) => tool.name),
@@ -153,7 +152,6 @@ class AgiLoop extends import_harness.AgentLoop {
153
152
  const blocked = ready.filter((action) => harness.requiresApproval(action));
154
153
  const runnable = ready.filter((action) => !blocked.includes(action));
155
154
  if (runnable.length) {
156
- if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity(`Running ${runnable.map((action) => action.name).join(", ")}...`);
157
155
  await Promise.all(runnable.map((action) => harness.runAction(action, { blockDuplicates: BLOCK_DUPLICATES })));
158
156
  }
159
157
  if (blocked.length) {
@@ -28,7 +28,7 @@ class AgiLoop extends AgentLoop {
28
28
  return "agi";
29
29
  }
30
30
  get version() {
31
- return "1.8.1";
31
+ return "1.8.7";
32
32
  }
33
33
  get author() {
34
34
  return {
@@ -50,7 +50,6 @@ class AgiLoop extends AgentLoop {
50
50
  harness.setNextNode(this.nodes.reasoning_engine);
51
51
  return;
52
52
  }
53
- ctx.chat.state?.setCurrentActivity("Analyzing requirement...");
54
53
  const chat_history = ctx.chat.lastHistoryMessages();
55
54
  const agentIdentity = ctx.identity;
56
55
  const result = await fastResponder.run({
@@ -63,7 +62,7 @@ class AgiLoop extends AgentLoop {
63
62
  ctx.chat.state?.setLanguage(result.detected_language);
64
63
  if (!result.can_answer) {
65
64
  const activity = cleanActivity(result.activity);
66
- if (activity) ctx.chat.state?.setCurrentActivity(activity, "model");
65
+ if (activity) ctx.chat.state?.setCurrentActivity(activity);
67
66
  harness.setNextNode(this.nodes.reasoning_engine);
68
67
  } else {
69
68
  ctx.chat.state?.setStatus(AgentStatus.IDLE);
@@ -72,7 +71,6 @@ class AgiLoop extends AgentLoop {
72
71
  }
73
72
  }
74
73
  async reasoningEngine(ctx, harness) {
75
- if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity("Thinking...");
76
74
  const task = ctx.task ?? ctx.chat.createTask(ctx.currentMessage);
77
75
  task.answerQuestion(ctx.currentMessage);
78
76
  const streak = task.sameToolStreak;
@@ -86,6 +84,7 @@ class AgiLoop extends AgentLoop {
86
84
  const catalog = await harness.toolCatalog();
87
85
  const result = await reasoningEngine.run({
88
86
  ...ctx.skillParams,
87
+ thinking: ctx.thinkingEffort,
89
88
  history: task.history({
90
89
  budget: { turns_left: MAX_TURNS - task.turnCount, tool_calls_left: MAX_TOOL_CALLS - task.toolCallCount },
91
90
  ...warning ? { warning } : {},
@@ -106,7 +105,7 @@ class AgiLoop extends AgentLoop {
106
105
  if (/^[a-z]{2}$/.test(language)) ctx.chat.state?.setLanguage(language);
107
106
  const { rawText, ...callInfo } = result.callInfo;
108
107
  const activity = cleanActivity(result.activity);
109
- if (activity) ctx.chat.state?.setCurrentActivity(activity, "model");
108
+ if (activity) ctx.chat.state?.setCurrentActivity(activity);
110
109
  task.addTurn({ ...result, activity }, {
111
110
  author: "reasoning_engine",
112
111
  declaredTools: catalog.tools.map((tool) => tool.name),
@@ -131,7 +130,6 @@ class AgiLoop extends AgentLoop {
131
130
  const blocked = ready.filter((action) => harness.requiresApproval(action));
132
131
  const runnable = ready.filter((action) => !blocked.includes(action));
133
132
  if (runnable.length) {
134
- if (!ctx.chat.state?.hasModelActivity) ctx.chat.state?.setCurrentActivity(`Running ${runnable.map((action) => action.name).join(", ")}...`);
135
133
  await Promise.all(runnable.map((action) => harness.runAction(action, { blockDuplicates: BLOCK_DUPLICATES })));
136
134
  }
137
135
  if (blocked.length) {
@@ -25,21 +25,22 @@ 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.5.0",
28
+ version: "2.5.4",
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
+ thinking: "medium",
31
32
  systemRole: true,
32
33
  systemInstructions: {
33
34
  instruction_set: {
34
35
  goal: "Fulfil the user's request (INPUT.user_message) by working in cycles: think, act, observe and continue from where you left off, until you can give a final answer with the respond action.",
35
36
  role: "You are the mind of an autonomous agent. The agent has a body, the runtime that hosts you (the harness), and you are what thinks and decides. Your body gives you hands, eyes, ears, a voice and a memory: it runs the actions you ask for, shows you their results as OBSERVATIONS, keeps your working state between cycles and delivers your answers to the user. You never execute anything yourself; everything you want to do in the world is an action that your body performs for you. Some of your tools are part of your body: search_tools (your eyes, to find external tools, present in your tool list only when the catalog is too large to list), read_context and save_context (a desk where you keep and reread data), ask_user (to pause and ask the person something) and respond (your voice, to give the final answer). Other tools are instruments of the outside world, such as apps, APIs and MCP servers, and their names carry the server as a prefix, like 'server__tool'; that prefix is part of the name and is always written. You work in cycles. In each cycle you receive the situation (the user's request the first time, then the results of your last actions), you think, you rewrite your state and you answer with your next actions. You never lose the thread: your previous reasoning and state come back to you in every cycle, so you continue from where you left off instead of starting over.",
36
37
  logic_rules: [
37
- "OUTPUT_FORMAT: Every response is a single JSON object with the fields 'reasoning', 'language', 'state' and 'actions' (never empty), and optionally 'learned'. Nothing outside that JSON.",
38
+ "OUTPUT_FORMAT: Every response is a single JSON object with the fields 'reasoning', 'language', 'state', 'actions' (never empty) and 'activity' (see ACTIVITY), and optionally 'learned'. Nothing outside that JSON.",
38
39
  "REASONING: Explain in a few sentences why you decide these actions now: what you learned from the last results, what is missing, and why these actions move you forward. It is kept for audit and debugging.",
39
40
  "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
41
  `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
42
  `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.",
43
+ "ACTIVITY: Always write 'activity'. 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 of at most 60 characters: a verb in the progressive form followed by what is being looked up or done, taken from the user's request. It must be in the language of 'language' and of the message of the user, never in the language of these instructions. Never mention tool names, ids, refs or technical terms, never include personal data, and do not promise a result. The only exception is when your actions just deliver the final answer: then leave it out.",
43
44
  "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.",
44
45
  `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.`,
45
46
  "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.",
@@ -3,21 +3,22 @@ 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.5.0",
6
+ version: "2.5.4",
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
+ thinking: "medium",
9
10
  systemRole: true,
10
11
  systemInstructions: {
11
12
  instruction_set: {
12
13
  goal: "Fulfil the user's request (INPUT.user_message) by working in cycles: think, act, observe and continue from where you left off, until you can give a final answer with the respond action.",
13
14
  role: "You are the mind of an autonomous agent. The agent has a body, the runtime that hosts you (the harness), and you are what thinks and decides. Your body gives you hands, eyes, ears, a voice and a memory: it runs the actions you ask for, shows you their results as OBSERVATIONS, keeps your working state between cycles and delivers your answers to the user. You never execute anything yourself; everything you want to do in the world is an action that your body performs for you. Some of your tools are part of your body: search_tools (your eyes, to find external tools, present in your tool list only when the catalog is too large to list), read_context and save_context (a desk where you keep and reread data), ask_user (to pause and ask the person something) and respond (your voice, to give the final answer). Other tools are instruments of the outside world, such as apps, APIs and MCP servers, and their names carry the server as a prefix, like 'server__tool'; that prefix is part of the name and is always written. You work in cycles. In each cycle you receive the situation (the user's request the first time, then the results of your last actions), you think, you rewrite your state and you answer with your next actions. You never lose the thread: your previous reasoning and state come back to you in every cycle, so you continue from where you left off instead of starting over.",
14
15
  logic_rules: [
15
- "OUTPUT_FORMAT: Every response is a single JSON object with the fields 'reasoning', 'language', 'state' and 'actions' (never empty), and optionally 'learned'. Nothing outside that JSON.",
16
+ "OUTPUT_FORMAT: Every response is a single JSON object with the fields 'reasoning', 'language', 'state', 'actions' (never empty) and 'activity' (see ACTIVITY), and optionally 'learned'. Nothing outside that JSON.",
16
17
  "REASONING: Explain in a few sentences why you decide these actions now: what you learned from the last results, what is missing, and why these actions move you forward. It is kept for audit and debugging.",
17
18
  "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
19
  `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
20
  `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.",
21
+ "ACTIVITY: Always write 'activity'. 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 of at most 60 characters: a verb in the progressive form followed by what is being looked up or done, taken from the user's request. It must be in the language of 'language' and of the message of the user, never in the language of these instructions. Never mention tool names, ids, refs or technical terms, never include personal data, and do not promise a result. The only exception is when your actions just deliver the final answer: then leave it out.",
21
22
  "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.",
22
23
  `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.`,
23
24
  "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.",
@@ -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.4.0",
28
+ version: "2.4.3",
29
29
  description: "Handles general conversations and multipurpose user assistance.",
30
30
  temperature: 0.7,
31
31
  thinking: "low",
@@ -42,7 +42,7 @@ const fastResponder = new import_skill.Skill({
42
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').",
43
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.",
44
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.",
45
+ "ACTIVITY: When 'can_answer' is false, always write in 'activity' one short sentence of at most 60 characters: a verb in the present or progressive form followed by what you will look up or do, taken from the user's request. It must be in 'detected_language' and match the language of the message of the user, never the language of these instructions. Never mention tool names or technical terms, never include personal data, and do not promise a result. Leave it empty when 'can_answer' is true.",
46
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.",
47
47
  import_shared_rules.FORMATTING,
48
48
  import_shared_rules.LATEX_FORMATTING,
@@ -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.4.0",
6
+ version: "2.4.3",
7
7
  description: "Handles general conversations and multipurpose user assistance.",
8
8
  temperature: 0.7,
9
9
  thinking: "low",
@@ -20,7 +20,7 @@ const fastResponder = new Skill({
20
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').",
21
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.",
22
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.",
23
+ "ACTIVITY: When 'can_answer' is false, always write in 'activity' one short sentence of at most 60 characters: a verb in the present or progressive form followed by what you will look up or do, taken from the user's request. It must be in 'detected_language' and match the language of the message of the user, never the language of these instructions. Never mention tool names or technical terms, never include personal data, and do not promise a result. Leave it empty when 'can_answer' is true.",
24
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.",
25
25
  FORMATTING,
26
26
  LATEX_FORMATTING,
@@ -1,3 +1,4 @@
1
+ import type { SelectableThinkingEffort } from '../../../clients/llm/llm-types.js';
1
2
  export type ExecutionMode = 'interactive' | 'autonomous';
2
3
  export interface ChatSettingsProps {
3
4
  notifyOnCompletion?: boolean;
@@ -6,6 +7,7 @@ export interface ChatSettingsProps {
6
7
  modelName?: string;
7
8
  loopName?: string;
8
9
  executionMode?: ExecutionMode;
10
+ thinkingEffort?: SelectableThinkingEffort;
9
11
  }
10
12
  export declare class ChatSettings {
11
13
  private readonly props;
@@ -15,11 +17,13 @@ export declare class ChatSettings {
15
17
  modelName?: string | undefined;
16
18
  loopName?: string | undefined;
17
19
  executionMode?: ExecutionMode | undefined;
18
- constructor(props: ChatSettingsProps, notifyOnCompletion?: boolean | undefined, isPrivateSession?: boolean | undefined, modelProvider?: string | undefined, modelName?: string | undefined, loopName?: string | undefined, executionMode?: ExecutionMode | undefined);
20
+ thinkingEffort?: SelectableThinkingEffort | undefined;
21
+ constructor(props: ChatSettingsProps, notifyOnCompletion?: boolean | undefined, isPrivateSession?: boolean | undefined, modelProvider?: string | undefined, modelName?: string | undefined, loopName?: string | undefined, executionMode?: ExecutionMode | undefined, thinkingEffort?: SelectableThinkingEffort | undefined);
19
22
  static fromJSON(props: ChatSettingsProps): ChatSettings;
20
23
  toJSON(): ChatSettingsProps;
21
24
  setLoopName(loopName: string): void;
22
25
  setExecutionMode(executionMode: ExecutionMode): void;
26
+ setThinkingEffort(thinkingEffort: SelectableThinkingEffort): void;
23
27
  setModelProvider(modelProvider: string): void;
24
28
  setModelName(modelName: string): void;
25
29
  setNotifyOnCompletion(notifyOnCompletion: boolean): void;
@@ -22,7 +22,7 @@ __export(chat_settings_entity_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(chat_settings_entity_exports);
24
24
  class ChatSettings {
25
- constructor(props, notifyOnCompletion, isPrivateSession, modelProvider, modelName, loopName, executionMode) {
25
+ constructor(props, notifyOnCompletion, isPrivateSession, modelProvider, modelName, loopName, executionMode, thinkingEffort) {
26
26
  this.props = props;
27
27
  this.notifyOnCompletion = notifyOnCompletion;
28
28
  this.isPrivateSession = isPrivateSession;
@@ -30,6 +30,7 @@ class ChatSettings {
30
30
  this.modelName = modelName;
31
31
  this.loopName = loopName;
32
32
  this.executionMode = executionMode;
33
+ this.thinkingEffort = thinkingEffort;
33
34
  }
34
35
  props;
35
36
  notifyOnCompletion;
@@ -38,6 +39,7 @@ class ChatSettings {
38
39
  modelName;
39
40
  loopName;
40
41
  executionMode;
42
+ thinkingEffort;
41
43
  static fromJSON(props) {
42
44
  return new ChatSettings(
43
45
  props,
@@ -46,7 +48,8 @@ class ChatSettings {
46
48
  props.modelProvider,
47
49
  props.modelName,
48
50
  props.loopName,
49
- props.executionMode
51
+ props.executionMode,
52
+ props.thinkingEffort
50
53
  );
51
54
  }
52
55
  toJSON() {
@@ -56,7 +59,8 @@ class ChatSettings {
56
59
  modelProvider: this.modelProvider,
57
60
  modelName: this.modelName,
58
61
  loopName: this.loopName,
59
- executionMode: this.executionMode
62
+ executionMode: this.executionMode,
63
+ thinkingEffort: this.thinkingEffort
60
64
  };
61
65
  }
62
66
  setLoopName(loopName) {
@@ -65,6 +69,9 @@ class ChatSettings {
65
69
  setExecutionMode(executionMode) {
66
70
  this.executionMode = executionMode;
67
71
  }
72
+ setThinkingEffort(thinkingEffort) {
73
+ this.thinkingEffort = thinkingEffort;
74
+ }
68
75
  setModelProvider(modelProvider) {
69
76
  this.modelProvider = modelProvider;
70
77
  }
@@ -1,6 +1,6 @@
1
1
  import "../../../chunk-CF3WOMB3.mjs";
2
2
  class ChatSettings {
3
- constructor(props, notifyOnCompletion, isPrivateSession, modelProvider, modelName, loopName, executionMode) {
3
+ constructor(props, notifyOnCompletion, isPrivateSession, modelProvider, modelName, loopName, executionMode, thinkingEffort) {
4
4
  this.props = props;
5
5
  this.notifyOnCompletion = notifyOnCompletion;
6
6
  this.isPrivateSession = isPrivateSession;
@@ -8,6 +8,7 @@ class ChatSettings {
8
8
  this.modelName = modelName;
9
9
  this.loopName = loopName;
10
10
  this.executionMode = executionMode;
11
+ this.thinkingEffort = thinkingEffort;
11
12
  }
12
13
  props;
13
14
  notifyOnCompletion;
@@ -16,6 +17,7 @@ class ChatSettings {
16
17
  modelName;
17
18
  loopName;
18
19
  executionMode;
20
+ thinkingEffort;
19
21
  static fromJSON(props) {
20
22
  return new ChatSettings(
21
23
  props,
@@ -24,7 +26,8 @@ class ChatSettings {
24
26
  props.modelProvider,
25
27
  props.modelName,
26
28
  props.loopName,
27
- props.executionMode
29
+ props.executionMode,
30
+ props.thinkingEffort
28
31
  );
29
32
  }
30
33
  toJSON() {
@@ -34,7 +37,8 @@ class ChatSettings {
34
37
  modelProvider: this.modelProvider,
35
38
  modelName: this.modelName,
36
39
  loopName: this.loopName,
37
- executionMode: this.executionMode
40
+ executionMode: this.executionMode,
41
+ thinkingEffort: this.thinkingEffort
38
42
  };
39
43
  }
40
44
  setLoopName(loopName) {
@@ -43,6 +47,9 @@ class ChatSettings {
43
47
  setExecutionMode(executionMode) {
44
48
  this.executionMode = executionMode;
45
49
  }
50
+ setThinkingEffort(thinkingEffort) {
51
+ this.thinkingEffort = thinkingEffort;
52
+ }
46
53
  setModelProvider(modelProvider) {
47
54
  this.modelProvider = modelProvider;
48
55
  }
@@ -32,6 +32,7 @@ export interface SkillRunOptions<TInput = Record<string, any>> {
32
32
  chatHistory?: ChatTurn[];
33
33
  tools?: LLMToolDefinition[];
34
34
  mode?: SkillMode;
35
+ thinking?: ThinkingEffort;
35
36
  }
36
37
  export interface SkillCallInfo {
37
38
  skill: string;
@@ -47,7 +48,7 @@ export declare class Skill<TResponse = Record<string, any>> {
47
48
  readonly version?: string;
48
49
  readonly description?: string;
49
50
  readonly temperature?: number;
50
- readonly thinking?: ThinkingEffort;
51
+ readonly thinking: ThinkingEffort;
51
52
  readonly systemInstructions: Record<string, any>;
52
53
  readonly systemRole: boolean;
53
54
  readonly mode: SkillMode;
@@ -31,6 +31,7 @@ var import_runtime_context = require("./runtime-context");
31
31
  var import_call_modes = require("./call-modes");
32
32
  var import_call_modes2 = require("./call-modes");
33
33
  const RAW_RESPONSE_CHARS = 300;
34
+ const DEFAULT_THINKING_EFFORT = "low";
34
35
  const RESERVED_CONTEXT_KEYS = ["tools", "mode", "history", "chatHistory"];
35
36
  class Skill {
36
37
  name;
@@ -46,13 +47,13 @@ class Skill {
46
47
  this.version = props.version;
47
48
  this.description = props.description;
48
49
  this.temperature = props.temperature;
49
- this.thinking = props.thinking;
50
+ this.thinking = props.thinking ?? DEFAULT_THINKING_EFFORT;
50
51
  this.systemInstructions = props.systemInstructions;
51
52
  this.systemRole = props.systemRole ?? true;
52
53
  this.mode = props.mode ?? import_call_modes.DEFAULT_SKILL_MODE;
53
54
  }
54
55
  async run(options) {
55
- const { provider, modelName, sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat, history = [], chatHistory = [], tools, mode = this.mode } = options;
56
+ const { provider, modelName, sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat, history = [], chatHistory = [], tools, mode = this.mode, thinking = this.thinking } = options;
56
57
  const misplaced = RESERVED_CONTEXT_KEYS.filter((key) => key in contextInjection);
57
58
  if (misplaced.length) throw new Error(`[SKILL:${this.name}] ${misplaced.join(", ")} must be passed as run options, not inside contextInjection`);
58
59
  if (history.length && chatHistory.length) throw new Error(`[SKILL:${this.name}] history and chatHistory cannot be used together`);
@@ -81,7 +82,7 @@ class Skill {
81
82
  tools: call.tools,
82
83
  toolChoice: call.toolChoice,
83
84
  temperature: this.temperature ?? 0.7,
84
- ...this.thinking ? { thinking: this.thinking } : {}
85
+ thinking
85
86
  });
86
87
  const reading = (0, import_call_modes.readModeResponse)(mode, this.name, response, { expectActions: Boolean(tools?.length) });
87
88
  if (reading.blocks > 1) {
@@ -7,6 +7,7 @@ import { buildRuntimeContext } from "./runtime-context";
7
7
  import { DEFAULT_SKILL_MODE, buildModeCall, readModeResponse } from "./call-modes";
8
8
  import { SkillMode as SkillMode2, DEFAULT_SKILL_MODE as DEFAULT_SKILL_MODE2 } from "./call-modes";
9
9
  const RAW_RESPONSE_CHARS = 300;
10
+ const DEFAULT_THINKING_EFFORT = "low";
10
11
  const RESERVED_CONTEXT_KEYS = ["tools", "mode", "history", "chatHistory"];
11
12
  class Skill {
12
13
  name;
@@ -22,13 +23,13 @@ class Skill {
22
23
  this.version = props.version;
23
24
  this.description = props.description;
24
25
  this.temperature = props.temperature;
25
- this.thinking = props.thinking;
26
+ this.thinking = props.thinking ?? DEFAULT_THINKING_EFFORT;
26
27
  this.systemInstructions = props.systemInstructions;
27
28
  this.systemRole = props.systemRole ?? true;
28
29
  this.mode = props.mode ?? DEFAULT_SKILL_MODE;
29
30
  }
30
31
  async run(options) {
31
- const { provider, modelName, sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat, history = [], chatHistory = [], tools, mode = this.mode } = options;
32
+ const { provider, modelName, sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat, history = [], chatHistory = [], tools, mode = this.mode, thinking = this.thinking } = options;
32
33
  const misplaced = RESERVED_CONTEXT_KEYS.filter((key) => key in contextInjection);
33
34
  if (misplaced.length) throw new Error(`[SKILL:${this.name}] ${misplaced.join(", ")} must be passed as run options, not inside contextInjection`);
34
35
  if (history.length && chatHistory.length) throw new Error(`[SKILL:${this.name}] history and chatHistory cannot be used together`);
@@ -57,7 +58,7 @@ class Skill {
57
58
  tools: call.tools,
58
59
  toolChoice: call.toolChoice,
59
60
  temperature: this.temperature ?? 0.7,
60
- ...this.thinking ? { thinking: this.thinking } : {}
61
+ thinking
61
62
  });
62
63
  const reading = readModeResponse(mode, this.name, response, { expectActions: Boolean(tools?.length) });
63
64
  if (reading.blocks > 1) {
package/docs/agent.md CHANGED
@@ -64,6 +64,7 @@ Omit `chatId` to start a brand-new chat. Pass an existing `chatId` to continue a
64
64
  | Option | What it does |
65
65
  | --- | --- |
66
66
  | `modelProvider`, `modelName` | Model for this run, always together. It is saved in the chat and used by the next runs that do not send one. Without it, the model comes from the chat, the preference of the user and the fallbacks. See [configuration](configuration.md#which-model-a-chat-uses). |
67
+ | `thinkingEffort` | `low`, `medium` or `high`: how much the reasoning engine thinks before each response. Any other value makes the run fail before calling the model. It is saved in the chat only when you send it, and the next runs that do not send one reuse it. Without it, the reasoning engine uses `medium`. `high` is slower, so its model calls get twice the time limit (see [Timeouts](configuration.md#timeouts)). It does not change the fast responder, which always uses `low`. |
67
68
  | `loopName` | Name of the loop driving the chat. Set automatically from the loop. |
68
69
  | `executionMode` | `interactive` (default) or `autonomous`. See [Autonomous mode](#autonomous-mode). |
69
70
  | `notifyOnCompletion` | Exposed as `agent.notifyOnCompletion` so a post execution hook can notify the user. |
@@ -198,7 +199,7 @@ await agent.run({ input: { chatId, message }, currentUser })
198
199
  stop()
199
200
  ```
200
201
 
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
+ The listener receives every change of the activity of the run while it is in progress. It gets no start or end marker: the run is over when `agent.run()` resolves. 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 listener hears nothing and the client keeps what it shows. See [loops](loops.md#agiloop).
202
203
 
203
204
  - 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
205
  - 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/chats.md CHANGED
@@ -11,7 +11,7 @@ import { createChat, getChatById, listChatsByUser, updateChat, deleteChat } from
11
11
  | Field | Meaning |
12
12
  | --- | --- |
13
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
- | `settings` | `modelProvider` and `modelName` (the model the chat uses, saved on every run), `loopName`, `executionMode`, `notifyOnCompletion` and `isPrivateSession`. |
14
+ | `settings` | `modelProvider` and `modelName` (the model the chat uses, saved on every run), `thinkingEffort` (only when a run sent it), `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
17
  ### `state.currentActivity` is deprecated
@@ -17,7 +17,7 @@
17
17
  | `AGENTIC_JOBS_POLL_INTERVAL_MS` | no | How often the runner of [agentic jobs](agentic-jobs.md) checks what is due, in milliseconds. Defaults to `60000`. |
18
18
  | `AGENTIC_JOBS_LEASE_MS` | no | How long a job stays locked while it runs, in milliseconds. Defaults to `600000`. |
19
19
  | `LLM_FALLBACK_PROVIDER`, `LLM_FALLBACK_MODEL` | no | The model to use when nothing else chooses one, for the whole deployment. Set both or neither. See [Which model a chat uses](#which-model-a-chat-uses). |
20
- | `LLM_CALL_TIMEOUT_MS` | no | Longest time to wait for one attempt of a model call, in milliseconds. Defaults to `60000`. See [Timeouts](#timeouts). |
20
+ | `LLM_CALL_TIMEOUT_MS` | no | Longest time to wait for one attempt of a model call, in milliseconds. Defaults to `60000`, and calls with the `high` thinking effort get twice as much. See [Timeouts](#timeouts). |
21
21
  | `MCP_TOOL_TIMEOUT_MS` | no | Longest time to wait for a tool of an MCP server, in milliseconds. Defaults to `60000`. See [Timeouts](#timeouts). |
22
22
  | `SENTRY_DSN` | no | Errors are reported to Sentry when set, unless `IS_LOCAL` is `true` or `NODE_ENV` is `development`. |
23
23
  | `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, `LANGFUSE_BASE_URL` | no | Traces every LLM call in Langfuse when all three are set. |
@@ -57,7 +57,7 @@ It is in the low price tier, it makes the most of the prompt cache, which matter
57
57
 
58
58
  A model call that never answers would block the whole run, so every attempt has a time limit:
59
59
 
60
- - **Model calls.** An attempt that does not answer within `LLM_CALL_TIMEOUT_MS` (60 seconds by default) is cancelled and the same call is made again, up to 3 attempts in total. When all of them time out, the run fails with the error code `LLM_TIMEOUT` and a message for the user, and the chat is left as `failed` so the user can send the message again. Waiting for a provider that asks to slow down is a separate mechanism and is not affected.
60
+ - **Model calls.** An attempt that does not answer within `LLM_CALL_TIMEOUT_MS` (60 seconds by default) is cancelled and the same call is made again, up to 3 attempts in total. A call with the `high` thinking effort, which thinks for longer, gets twice that time. When all of them time out, the run fails with the error code `LLM_TIMEOUT` and a message for the user, and the chat is left as `failed` so the user can send the message again. Waiting for a provider that asks to slow down is a separate mechanism and is not affected.
61
61
  - **Tools of MCP servers.** A tool that does not answer within `MCP_TOOL_TIMEOUT_MS` (60 seconds by default) fails. The time starts again every time the server reports progress, so a long tool that is alive is not cut off. A tool call is never repeated automatically, because it may have changed something. The model is told that the result is unknown and that it must check before repeating it.
62
62
  - **Langfuse.** Sending the trace of a call to Langfuse waits at most 5 seconds. If it takes longer or fails, the run continues without it.
63
63
 
package/docs/loops.md CHANGED
@@ -17,7 +17,7 @@ import { AgiLoop } from 'openloops/loops'
17
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 keeps the last one the model gave, also when the answer of a turn is not valid and the model has to try again, and it shows the generic activity of that moment (`Thinking...`, `Running search...`) only while there is none. 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.
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. The loop never invents one: when a node leaves it out or writes something unusable (not a text, empty, `running`, `stopped`), the listener hears nothing and the last one the model gave stays, also when the answer of a turn is not valid and the model has to try again. 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
21
 
22
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.
23
23
 
package/docs/skills.md CHANGED
@@ -44,7 +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
+ | `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 it is `low`. Set `high` only for a skill that needs to reason at length, because it is slower and costs more. The bundled `fast_responder` uses `low` and the `reasoning_engine` uses `medium`. |
48
48
  | `systemRole` | no | Default `true`: the instructions travel as a system message. |
49
49
  | `mode` | no | How the model is called when tools are given. Defaults to `plain_chat`. |
50
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openloops",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
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",