@game_ryo/lsji 1.2.3 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@game_ryo/lsji",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "A general-purpose reinforcement learning agent framework (Node.js) with LLM agent capabilities",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -96,4 +96,4 @@ export {
96
96
  } from './llm/plugins/index.js';
97
97
 
98
98
  // Version
99
- export const VERSION = '1.2.3';
99
+ export const VERSION = '1.2.5';
@@ -184,6 +184,7 @@ export class LLMAgent {
184
184
  maxTokens: 4096,
185
185
  });
186
186
 
187
+
187
188
  // Record token usage
188
189
  if (this.memory.episodic) {
189
190
  this.memory.episodic.recordTokens(response.usage?.totalTokens || 0);
@@ -270,15 +271,34 @@ export class LLMAgent {
270
271
  }
271
272
 
272
273
  // No tool calls - check if final answer
273
- if (response.content && !response.content.includes('THOUGHT:') && !response.content.includes('ACTION:')) {
274
+ // Don't treat empty/whitespace-only content as final answer
275
+ const hasContent = response.content && response.content.trim().length > 0;
276
+ const isReActFormat = response.content && (response.content.includes('THOUGHT:') || response.content.includes('ACTION:'));
277
+ const isFinalAnswer = hasContent && !isReActFormat;
278
+
279
+ if (isFinalAnswer) {
274
280
  finalAnswer = response.content;
275
281
  break;
276
282
  }
277
283
 
278
- // Parse ReAct format if present
279
- if (response.content.includes('THOUGHT:') || response.content.includes('ACTION:')) {
284
+ // Parse ReAct format if present (THOUGHT: or ACTION:)
285
+ if (isReActFormat) {
280
286
  // This is a ReAct formatted response without tool calls
281
- // Continue to next iteration
287
+ // Check if it contains a final answer indicator
288
+ if (response.content.includes('FINAL ANSWER:') || response.content.includes('Final Answer:')) {
289
+ // Extract the final answer part
290
+ const finalAnswerMatch = response.content.match(/(?:FINAL ANSWER:|Final Answer:)\s*(.+)/i);
291
+ if (finalAnswerMatch) {
292
+ finalAnswer = finalAnswerMatch[1].trim();
293
+ break;
294
+ }
295
+ }
296
+ // Continue to next iteration for more ReAct steps
297
+ continue;
298
+ }
299
+
300
+ // Skip empty responses
301
+ if (!hasContent) {
282
302
  continue;
283
303
  }
284
304