| 1305 | } |
| 1306 | |
| 1307 | function insertReminders(input: { messages: MessageV2.WithParts[]; agent: Agent.Info }) { |
| 1308 | const userMessage = input.messages.findLast((msg) => msg.info.role === "user") |
| 1309 | if (!userMessage) return input.messages |
| 1310 | if (input.agent.name === "plan") { |
| 1311 | userMessage.parts.push({ |
| 1312 | id: Identifier.ascending("part"), |
| 1313 | messageID: userMessage.info.id, |
| 1314 | sessionID: userMessage.info.sessionID, |
| 1315 | type: "text", |
| 1316 | // TODO (for mr dax): update to use the anthropic full fledged one (see plan-reminder-anthropic.txt) |
| 1317 | text: PROMPT_PLAN, |
| 1318 | synthetic: true, |
| 1319 | }) |
| 1320 | } |
| 1321 | const wasPlan = input.messages.some((msg) => msg.info.role === "assistant" && msg.info.mode === "plan") |
| 1322 | if (wasPlan && input.agent.name === "build") { |
| 1323 | userMessage.parts.push({ |
| 1324 | id: Identifier.ascending("part"), |
| 1325 | messageID: userMessage.info.id, |
| 1326 | sessionID: userMessage.info.sessionID, |
| 1327 | type: "text", |
| 1328 | text: BUILD_SWITCH, |
| 1329 | synthetic: true, |
| 1330 | }) |
| 1331 | } |
| 1332 | return input.messages |
| 1333 | } |
| 1334 | |
| 1335 | export const ShellInput = z.object({ |
| 1336 | sessionID: Identifier.schema("session"), |