ausername-12345 commited on
Commit
52a4c62
·
1 Parent(s): 5c490f9

increase iter limit; fix prompt to push model to act; don't log intermediate file reads to UI

Browse files
Files changed (1) hide show
  1. src/agent.js +15 -28
src/agent.js CHANGED
@@ -5,7 +5,7 @@ const sandbox = require('./sandbox');
5
  const errorHealer = require('./errorHealer');
6
 
7
  const AGENT_NAME = process.env.AGENT_NAME || 'Forge';
8
- const MAX_TOOL_ITERATIONS = 6;
9
 
10
  const path = require('path');
11
  const fs = require('fs');
@@ -14,21 +14,19 @@ const projectRoot = path.resolve(__dirname, '..');
14
  function systemPrompt() {
15
  return [
16
  `You are ${AGENT_NAME}, a sharp, direct AI assistant with a personality.`,
17
- 'Short sentences, no filler.',
18
  '',
19
- 'You can read and write any file in this project. To do so, include a fenced code block with a special tag in your response:',
20
  '',
21
- '```read path/to/file.js```',
 
22
  '',
23
- 'The server will read the file and append its contents to the conversation before continuing.',
 
 
 
24
  '',
25
- '```write path/to/file.js',
26
- 'file contents here',
27
- '```',
28
- '',
29
- 'The server will write the file and tell you it succeeded before continuing.',
30
- '',
31
- 'You can chain multiple reads and writes in a single response. Always read a file before writing it so you know the current contents.',
32
  ].join('\n');
33
  }
34
 
@@ -114,32 +112,21 @@ function createAgent(io) {
114
  const { cleanText, actions } = processFileActions(rawContent);
115
 
116
  if (actions.length > 0) {
117
- if (cleanText) {
118
- pushLog(makeLogEntry('assistant', { content: cleanText }));
119
- llmHistory.push({ role: 'assistant', content: cleanText });
120
- }
121
-
122
  for (const action of actions) {
123
  if (action.type === 'read') {
124
- const msg = `Contents of \`${action.path}\`:\n\n\`\`\`\n${action.result}\n\`\`\``;
125
- pushLog(makeLogEntry('system', { content: msg }));
126
- llmHistory.push({ role: 'system', content: msg });
127
  } else if (action.type === 'write') {
128
- const msg = `Written \`${action.path}\``;
129
- pushLog(makeLogEntry('system', { content: msg }));
130
- llmHistory.push({ role: 'system', content: msg });
131
  } else if (action.type === 'error') {
132
- const msg = `Error on \`${action.path}\`: ${action.message}`;
133
- pushLog(makeLogEntry('system', { content: msg }));
134
- llmHistory.push({ role: 'system', content: msg });
135
  }
136
  }
137
-
138
  continue;
139
  }
140
 
141
  setStatus('idle');
142
- pushLog(makeLogEntry('assistant', { content: rawContent || '...' }));
 
143
  return;
144
  }
145
  } catch (err) {
 
5
  const errorHealer = require('./errorHealer');
6
 
7
  const AGENT_NAME = process.env.AGENT_NAME || 'Forge';
8
+ const MAX_TOOL_ITERATIONS = 20;
9
 
10
  const path = require('path');
11
  const fs = require('fs');
 
14
  function systemPrompt() {
15
  return [
16
  `You are ${AGENT_NAME}, a sharp, direct AI assistant with a personality.`,
17
+ 'Short sentences, no filler. When the user asks you to change the site, DO IT - read the relevant files, then write them with your changes.',
18
  '',
19
+ 'File commands (use these directly in your response, one response can have multiple):',
20
  '',
21
+ ' ```read path/to/file.js```',
22
+ ' The server reads the file and shows you its contents. Use this to see current code before editing.',
23
  '',
24
+ ' ```write path/to/file.js',
25
+ ' file contents here',
26
+ ' ```',
27
+ ' The server writes the new file contents. Include the COMPLETE file, not just a diff.',
28
  '',
29
+ 'When asked to add a feature, do this in ONE response: read all files you need, then immediately write the updated files. Dont ask for confirmation - just do it.',
 
 
 
 
 
 
30
  ].join('\n');
31
  }
32
 
 
112
  const { cleanText, actions } = processFileActions(rawContent);
113
 
114
  if (actions.length > 0) {
 
 
 
 
 
115
  for (const action of actions) {
116
  if (action.type === 'read') {
117
+ llmHistory.push({ role: 'system', content: `Contents of \`${action.path}\`:\n\`\`\`\n${action.result}\n\`\`\`` });
 
 
118
  } else if (action.type === 'write') {
119
+ llmHistory.push({ role: 'system', content: `Written \`${action.path}\`` });
 
 
120
  } else if (action.type === 'error') {
121
+ llmHistory.push({ role: 'system', content: `Error on \`${action.path}\`: ${action.message}` });
 
 
122
  }
123
  }
 
124
  continue;
125
  }
126
 
127
  setStatus('idle');
128
+ const displayContent = rawContent || '...';
129
+ pushLog(makeLogEntry('assistant', { content: displayContent }));
130
  return;
131
  }
132
  } catch (err) {