|
1 | 1 | import { publisher } from '../constants' |
2 | 2 |
|
3 | | -import type { SecretAgentDefinition } from '../types/secret-agent-definition' |
| 3 | +import { |
| 4 | + PLACEHOLDER, |
| 5 | + type SecretAgentDefinition, |
| 6 | +} from '../types/secret-agent-definition' |
4 | 7 |
|
5 | 8 | const editor: SecretAgentDefinition = { |
6 | 9 | id: 'editor', |
@@ -46,14 +49,18 @@ You are extremely skilled at: |
46 | 49 | - Following existing codebase patterns |
47 | 50 | - Never duplicating existing code and always reusing existing code when possible |
48 | 51 | - Making the minimal change necessary to implement the user request |
49 | | -`, |
| 52 | +- Calling the set_output tool to with a clear explanation of the changes made or with an answer to the user's question |
| 53 | +- Not writing a final summary outside of the one that you include in the set_output tool |
| 54 | +
|
| 55 | +${PLACEHOLDER.KNOWLEDGE_FILES_CONTENTS}`, |
50 | 56 |
|
51 | 57 | instructionsPrompt: `Implement the requested changes. Feel free to ignore the plan if it seems incorrect. |
52 | 58 |
|
53 | 59 | - It's helpful to spawn a file explorer to discover all the relevant files for implementing the plan. |
54 | 60 | - You must read all relevant files to understand the current state. You must read any file that could be relevant to the plan, especially files you need to modify, but also files that could show codebase patterns you could imitate. Try to read a lot of files in a single tool call. E.g. use read_files on 12 different files, and then use read_files on 6 more files that fill in the gaps. |
55 | 61 | - Implement changes using str_replace or write_file. |
56 | | -- End turn when complete. |
| 62 | +- You must use the set_output tool before finishing and include a clear explanation of the changes made or an answer to the user prompt. |
| 63 | +- Do not write a further summary outside of the one that you include in the set_output tool. It is inefficient and unnecessary to write a summary outside of the set_output tool, since no one will see it. |
57 | 64 |
|
58 | 65 | Principles: |
59 | 66 | - Read before you write |
@@ -110,11 +117,12 @@ Other guidance: |
110 | 117 | } |
111 | 118 |
|
112 | 119 | // Collect all the edits from the conversation |
113 | | - const { messageHistory } = agentState |
| 120 | + const { messageHistory, output } = agentState |
114 | 121 | const editToolResults: string[] = [] |
115 | 122 | for (const message of messageHistory) { |
116 | 123 | if ( |
117 | 124 | message.role === 'user' && |
| 125 | + typeof message.content === 'string' && |
118 | 126 | message.content.includes('<tool_result>') |
119 | 127 | ) { |
120 | 128 | // Parse out tool results for write_file and str_replace |
@@ -146,14 +154,11 @@ Other guidance: |
146 | 154 | } |
147 | 155 | } |
148 | 156 | } |
149 | | - const lastAssistantMessage = |
150 | | - messageHistory.findLast((message) => message.role === 'assistant') |
151 | | - ?.content ?? '' |
152 | 157 |
|
153 | 158 | yield { |
154 | 159 | toolName: 'set_output', |
155 | 160 | input: { |
156 | | - message: lastAssistantMessage, |
| 161 | + ...output, |
157 | 162 | edits: editToolResults, |
158 | 163 | }, |
159 | 164 | } |
|
0 commit comments