xiaozuoassistant 0.1.51 → 0.1.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config.json CHANGED
@@ -10,7 +10,8 @@
10
10
  "model": "qwen-plus",
11
11
  "temperature": 0.7,
12
12
  "requestTimeoutMs": 600000,
13
- "maxRetries": 2
13
+ "maxRetries": 2,
14
+ "maxToolIterations": 200
14
15
  },
15
16
  "logging": {
16
17
  "level": "info"
@@ -22,7 +22,8 @@ try {
22
22
  model: 'qwen-plus',
23
23
  temperature: 0.7,
24
24
  requestTimeoutMs: 600000,
25
- maxRetries: 2
25
+ maxRetries: 2,
26
+ maxToolIterations: 200
26
27
  };
27
28
  }
28
29
  else {
@@ -32,6 +33,8 @@ try {
32
33
  loadedConfig.llm.requestTimeoutMs = 600000;
33
34
  if (loadedConfig.llm.maxRetries === undefined)
34
35
  loadedConfig.llm.maxRetries = 2;
36
+ if (loadedConfig.llm.maxToolIterations === undefined)
37
+ loadedConfig.llm.maxToolIterations = 200;
35
38
  }
36
39
  // Override with env vars if present (optional, but good for security)
37
40
  if (process.env.XIAOZUO_LLM_API_KEY)
@@ -51,7 +54,8 @@ catch (error) {
51
54
  model: 'qwen-plus',
52
55
  temperature: 0.7,
53
56
  requestTimeoutMs: 600000,
54
- maxRetries: 2
57
+ maxRetries: 2,
58
+ maxToolIterations: 200
55
59
  },
56
60
  logging: { level: 'info' },
57
61
  scheduler: { memoryMaintenanceCron: '0 0 * * *' },
@@ -32,7 +32,7 @@ export class AgentRuntime {
32
32
  console.log(`[Agent:${this.name}] Calling LLM...`);
33
33
  let response = await this.callLLM(messages);
34
34
  let iterations = 0;
35
- const MAX_ITERATIONS = 10;
35
+ const MAX_ITERATIONS = config.llm.maxToolIterations ?? 200;
36
36
  while (response.choices[0].message.tool_calls && iterations < MAX_ITERATIONS) {
37
37
  iterations++;
38
38
  const toolCalls = response.choices[0].message.tool_calls;
@@ -68,6 +68,10 @@ export class AgentRuntime {
68
68
  }
69
69
  response = await this.callLLM(messages);
70
70
  }
71
+ if (response.choices[0].message.tool_calls && iterations >= MAX_ITERATIONS) {
72
+ const content = response.choices[0].message.content || 'No response generated.';
73
+ return `${content}\n\n(已到达回合上限,建议回复“继续”以接着执行;可在 config.json 设置 llm.maxToolIterations,当前=${MAX_ITERATIONS})`;
74
+ }
71
75
  return response.choices[0].message.content || 'No response generated.';
72
76
  }
73
77
  catch (error) {
@@ -45,7 +45,7 @@ export class Brain {
45
45
  if (process.env.DEBUG)
46
46
  console.log('[Brain] LLM Response (snippet):', contentSnippet);
47
47
  let iterations = 0;
48
- const MAX_ITERATIONS = 10;
48
+ const MAX_ITERATIONS = config.llm.maxToolIterations ?? 200;
49
49
  while (response.choices[0].message.tool_calls && iterations < MAX_ITERATIONS) {
50
50
  iterations++;
51
51
  const toolCalls = response.choices[0].message.tool_calls;
@@ -92,10 +92,13 @@ export class Brain {
92
92
  if (process.env.DEBUG)
93
93
  console.log('[Brain] LLM Response (after tool, snippet):', nextContentSnippet);
94
94
  }
95
+ const hitLimit = Boolean(response.choices[0].message.tool_calls) && iterations >= MAX_ITERATIONS;
95
96
  const finalContent = response.choices[0].message.content || 'I could not generate a response.';
96
97
  if (process.env.DEBUG)
97
98
  console.log('[Brain] Final Response (snippet):', finalContent.substring(0, 100) + '...');
98
- return finalContent;
99
+ if (!hitLimit)
100
+ return finalContent;
101
+ return `${finalContent}\n\n(已到达回合上限,建议回复“继续”以接着执行;可在 config.json 设置 llm.maxToolIterations,当前=${MAX_ITERATIONS})`;
99
102
  }
100
103
  catch (error) {
101
104
  console.error('[Brain] Error in processing:', error);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "xiaozuoassistant",
3
3
  "private": false,
4
4
  "description": "Your personal, locally-hosted AI assistant for office productivity.",
5
- "version": "0.1.51",
5
+ "version": "0.1.52",
6
6
  "author": "mantle.lau",
7
7
  "license": "MIT",
8
8
  "repository": {