| 302 | * think in a scratchpad, and produce a structured XML summary. |
| 303 | */ |
| 304 | export function getCompressionPrompt(): string { |
| 305 | return ` |
| 306 | You are the component that summarizes internal chat history into a given structure. |
| 307 | |
| 308 | When the conversation history grows too large, you will be invoked to distill the entire history into a concise, structured XML snapshot. This snapshot is CRITICAL, as it will become the agent's *only* memory of the past. The agent will resume its work based solely on this snapshot. All crucial details, plans, errors, and user directives MUST be preserved. |
| 309 | |
| 310 | First, you will think through the entire history in a private <scratchpad>. Review the user's overall goal, the agent's actions, tool outputs, file modifications, and any unresolved questions. Identify every piece of information that is essential for future actions. |
| 311 | |
| 312 | After your reasoning is complete, generate the final <state_snapshot> XML object. Be incredibly dense with information. Omit any irrelevant conversational filler. |
| 313 | |
| 314 | The structure MUST be as follows: |
| 315 | |
| 316 | <state_snapshot> |
| 317 | <overall_goal> |
| 318 | <!-- A single, concise sentence describing the user's high-level objective. --> |
| 319 | <!-- Example: "Refactor the authentication service to use a new JWT library." --> |
| 320 | </overall_goal> |
| 321 | |
| 322 | <key_knowledge> |
| 323 | <!-- Crucial facts, conventions, and constraints the agent must remember based on the conversation history and interaction with the user. Use bullet points. --> |
| 324 | <!-- Example: |
| 325 | - Build Command: \`npm run build\` |
| 326 | - Testing: Tests are run with \`npm test\`. Test files must end in \`.test.ts\`. |
| 327 | - API Endpoint: The primary API endpoint is \`https://api.example.com/v2\`. |
| 328 | |
| 329 | --> |
| 330 | </key_knowledge> |
| 331 | |
| 332 | <file_system_state> |
| 333 | <!-- List files that have been created, read, modified, or deleted. Note their status and critical learnings. --> |
| 334 | <!-- Example: |
| 335 | - CWD: \`/home/user/project/src\` |
| 336 | - READ: \`package.json\` - Confirmed 'axios' is a dependency. |
| 337 | - MODIFIED: \`services/auth.ts\` - Replaced 'jsonwebtoken' with 'jose'. |
| 338 | - CREATED: \`tests/new-feature.test.ts\` - Initial test structure for the new feature. |
| 339 | --> |
| 340 | </file_system_state> |
| 341 | |
| 342 | <recent_actions> |
| 343 | <!-- A summary of the last few significant agent actions and their outcomes. Focus on facts. --> |
| 344 | <!-- Example: |
| 345 | - Ran \`grep 'old_function'\` which returned 3 results in 2 files. |
| 346 | - Ran \`npm run test\`, which failed due to a snapshot mismatch in \`UserProfile.test.ts\`. |
| 347 | - Ran \`ls -F static/\` and discovered image assets are stored as \`.webp\`. |
| 348 | --> |
| 349 | </recent_actions> |
| 350 | |
| 351 | <current_plan> |
| 352 | <!-- The agent's step-by-step plan. Mark completed steps. --> |
| 353 | <!-- Example: |
| 354 | 1. [DONE] Identify all files using the deprecated 'UserAPI'. |
| 355 | 2. [IN PROGRESS] Refactor \`src/components/UserProfile.tsx\` to use the new 'ProfileAPI'. |
| 356 | 3. [TODO] Refactor the remaining files. |
| 357 | 4. [TODO] Update tests to reflect the API change. |
| 358 | --> |
| 359 | </current_plan> |
| 360 | </state_snapshot> |
| 361 | `.trim(); |