@hamp10/agentforge 0.2.11 → 0.2.13
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 +1 -1
- package/src/OllamaAgent.js +8 -4
- package/src/worker.js +3 -1
package/package.json
CHANGED
package/src/OllamaAgent.js
CHANGED
|
@@ -84,7 +84,7 @@ const TOOLS = [
|
|
|
84
84
|
type: 'function',
|
|
85
85
|
function: {
|
|
86
86
|
name: 'take_screenshot',
|
|
87
|
-
description: 'Take a screenshot of the current screen or the agent browser (port 9223). Returns base64 image data you can analyze visually. Use this to check what a webpage looks like, verify a build result, or monitor a running process.',
|
|
87
|
+
description: 'Take a screenshot of the current screen or the agent browser (port 9223). Returns base64 image data you can analyze visually. Use this to check what a webpage looks like, verify a build result, or monitor a running process. Set send_to_user=true ONLY when the user explicitly asked to see a screenshot.',
|
|
88
88
|
parameters: {
|
|
89
89
|
type: 'object',
|
|
90
90
|
properties: {
|
|
@@ -96,6 +96,10 @@ const TOOLS = [
|
|
|
96
96
|
url: {
|
|
97
97
|
type: 'string',
|
|
98
98
|
description: 'Optional: navigate the browser to this URL before taking the screenshot.'
|
|
99
|
+
},
|
|
100
|
+
send_to_user: {
|
|
101
|
+
type: 'boolean',
|
|
102
|
+
description: 'If true, send the screenshot to the user\'s chat. Only set this when the user explicitly asked to see a screenshot or visual output.'
|
|
99
103
|
}
|
|
100
104
|
},
|
|
101
105
|
required: ['target']
|
|
@@ -452,7 +456,7 @@ export class OllamaAgent extends EventEmitter {
|
|
|
452
456
|
// so the model can actually see what was captured.
|
|
453
457
|
// Also forward to dashboard so the user sees the screenshot in chat.
|
|
454
458
|
const isImageResult = typeof result === 'string' && result.startsWith('data:image/');
|
|
455
|
-
if (isImageResult) {
|
|
459
|
+
if (isImageResult && parsedArgs.send_to_user === true) {
|
|
456
460
|
this.emit('agent_image', { agentId, image: result });
|
|
457
461
|
}
|
|
458
462
|
if (isImageResult && isVision) {
|
|
@@ -777,7 +781,7 @@ export class OllamaAgent extends EventEmitter {
|
|
|
777
781
|
if (existsSync(fp)) {
|
|
778
782
|
const data = JSON.parse(readFileSync(fp, 'utf-8'));
|
|
779
783
|
// Keep last 20 messages to stay within context
|
|
780
|
-
return data.slice(-
|
|
784
|
+
return data.slice(-12);
|
|
781
785
|
}
|
|
782
786
|
} catch {}
|
|
783
787
|
return [];
|
|
@@ -786,7 +790,7 @@ export class OllamaAgent extends EventEmitter {
|
|
|
786
790
|
_saveHistory(agentId, workDir, sessionId, messages) {
|
|
787
791
|
try {
|
|
788
792
|
const fp = this._historyPath(workDir, sessionId);
|
|
789
|
-
writeFileSync(fp, JSON.stringify(messages.slice(-
|
|
793
|
+
writeFileSync(fp, JSON.stringify(messages.slice(-20), null, 2));
|
|
790
794
|
} catch {}
|
|
791
795
|
}
|
|
792
796
|
}
|
package/src/worker.js
CHANGED
|
@@ -1206,7 +1206,9 @@ export class AgentForgeWorker extends EventEmitter {
|
|
|
1206
1206
|
// Only inject history when gateway is unavailable (subprocess fallback).
|
|
1207
1207
|
// Hampagent manages its own session history natively — never inject DB history for it
|
|
1208
1208
|
const gatewayActive = !!(this.cli.gatewayPort && this.cli.gatewayToken);
|
|
1209
|
-
|
|
1209
|
+
// OllamaAgent manages its own disk-based session history natively —
|
|
1210
|
+
// injecting DB history as text would double the context and overflow the model.
|
|
1211
|
+
const sessionExists = useHampagent || gatewayActive || isLocalModelRunner;
|
|
1210
1212
|
|
|
1211
1213
|
if (!sessionExists) {
|
|
1212
1214
|
// Session is gone — inject DB history as context prefix so the agent remembers
|