@hamp10/agentforge 0.2.3 → 0.2.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/OllamaAgent.js +45 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamp10/agentforge",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "AgentForge worker — connect your machine to agentforge.ai",
5
5
  "type": "module",
6
6
  "bin": {
@@ -407,6 +407,51 @@ export class OllamaAgent extends EventEmitter {
407
407
  finalContent = allOutput;
408
408
  }
409
409
 
410
+ // If still no output (model did only tool calls, never wrote text), ask for a summary
411
+ if (!finalContent && !controller.signal.aborted) {
412
+ this.emit('agent_output', { agentId, output: '\n' });
413
+ messages.push({ role: 'user', content: 'Summarize what you just did and show me the result.' });
414
+
415
+ try {
416
+ const summaryRes = await fetch(`${this.baseUrl}/v1/chat/completions`, {
417
+ method: 'POST',
418
+ headers: { 'Content-Type': 'application/json' },
419
+ signal: controller.signal,
420
+ body: JSON.stringify({
421
+ model: this.model,
422
+ messages,
423
+ stream: true,
424
+ ...(isQwen3 ? { options: { think: false } } : {})
425
+ })
426
+ });
427
+
428
+ if (summaryRes.ok) {
429
+ const reader = summaryRes.body.getReader();
430
+ const decoder = new TextDecoder();
431
+ let buf = '';
432
+ while (true) {
433
+ const { done, value } = await reader.read();
434
+ if (done) break;
435
+ buf += decoder.decode(value, { stream: true });
436
+ const lines = buf.split('\n');
437
+ buf = lines.pop();
438
+ for (const line of lines) {
439
+ if (!line.startsWith('data: ')) continue;
440
+ const payload = line.slice(6).trim();
441
+ if (payload === '[DONE]') continue;
442
+ let evt;
443
+ try { evt = JSON.parse(payload); } catch { continue; }
444
+ const text = evt.choices?.[0]?.delta?.content;
445
+ if (text) {
446
+ finalContent += text;
447
+ this.emit('agent_output', { agentId, output: text });
448
+ }
449
+ }
450
+ }
451
+ }
452
+ } catch {}
453
+ }
454
+
410
455
  // Persist history for next task
411
456
  if (finalContent && sessionId) {
412
457
  this._saveHistory(agentId, workDir, sessionId, [