mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 07:03:25 +00:00
Use structured output format for compaction and branch summarization
Both now use consistent sections: - Goal - Constraints & Preferences - Progress (Done/In Progress/Blocked) - Key Decisions - Next Steps - Critical Context (compaction only) Prompts instruct LLM to use EXACT format and preserve file paths/function names.
This commit is contained in:
parent
d1a49c45ff
commit
ac71aac090
2 changed files with 69 additions and 21 deletions
|
|
@ -259,13 +259,34 @@ export function prepareBranchEntries(entries: SessionEntry[], tokenBudget: numbe
|
||||||
// Summary Generation
|
// Summary Generation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
const BRANCH_SUMMARY_PROMPT = `Summarize this conversation branch concisely for context when returning later:
|
const BRANCH_SUMMARY_PROMPT = `Create a structured summary of this conversation branch for context when returning later.
|
||||||
- Key decisions made and actions taken
|
|
||||||
- Important context, constraints, or preferences discovered
|
|
||||||
- Current state and any pending work
|
|
||||||
- Critical information needed to continue from a different point
|
|
||||||
|
|
||||||
Be brief and focused on what matters for future reference.`;
|
Use this EXACT format:
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
[1-2 sentences: What was the user trying to accomplish in this branch?]
|
||||||
|
|
||||||
|
## Constraints & Preferences
|
||||||
|
- [Any constraints, preferences, or requirements mentioned]
|
||||||
|
- [Or "(none)" if none were mentioned]
|
||||||
|
|
||||||
|
## Progress
|
||||||
|
### Done
|
||||||
|
- [x] [Completed tasks/changes]
|
||||||
|
|
||||||
|
### In Progress
|
||||||
|
- [ ] [Work that was started but not finished]
|
||||||
|
|
||||||
|
### Blocked
|
||||||
|
- [Issues preventing progress, if any]
|
||||||
|
|
||||||
|
## Key Decisions
|
||||||
|
- **[Decision]**: [Brief rationale]
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
1. [What should happen next to continue this work]
|
||||||
|
|
||||||
|
Keep each section concise. Preserve exact file paths, function names, and error messages.`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert messages to text for the summarization prompt.
|
* Convert messages to text for the summarization prompt.
|
||||||
|
|
|
||||||
|
|
@ -328,16 +328,38 @@ export function findCutPoint(
|
||||||
// Summarization
|
// Summarization
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
const SUMMARIZATION_PROMPT = `You are performing a CONTEXT CHECKPOINT COMPACTION. Create a handoff summary for another LLM that will resume the task.
|
const SUMMARIZATION_PROMPT = `Create a structured context checkpoint summary. Another LLM will use this to continue the work.
|
||||||
|
|
||||||
Include:
|
Use this EXACT format:
|
||||||
- Current progress and key decisions made
|
|
||||||
- Important context, constraints, or user preferences
|
|
||||||
- Absolute file paths of any relevant files that were read or modified
|
|
||||||
- What remains to be done (clear next steps)
|
|
||||||
- Any critical data, examples, or references needed to continue
|
|
||||||
|
|
||||||
Be concise, structured, and focused on helping the next LLM seamlessly continue the work.`;
|
## Goal
|
||||||
|
[1-2 sentences: What is the user trying to accomplish?]
|
||||||
|
|
||||||
|
## Constraints & Preferences
|
||||||
|
- [Any constraints, preferences, or requirements mentioned by user]
|
||||||
|
- [Or "(none)" if none were mentioned]
|
||||||
|
|
||||||
|
## Progress
|
||||||
|
### Done
|
||||||
|
- [x] [Completed tasks/changes]
|
||||||
|
|
||||||
|
### In Progress
|
||||||
|
- [ ] [Current work]
|
||||||
|
|
||||||
|
### Blocked
|
||||||
|
- [Issues preventing progress, if any]
|
||||||
|
|
||||||
|
## Key Decisions
|
||||||
|
- **[Decision]**: [Brief rationale]
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
1. [Ordered list of what should happen next]
|
||||||
|
|
||||||
|
## Critical Context
|
||||||
|
- [Any data, examples, or references needed to continue]
|
||||||
|
- [Or "(none)" if not applicable]
|
||||||
|
|
||||||
|
Keep each section concise. Preserve exact file paths, function names, and error messages.`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a summary of the conversation using the LLM.
|
* Generate a summary of the conversation using the LLM.
|
||||||
|
|
@ -451,15 +473,20 @@ export function prepareCompaction(
|
||||||
// Main compaction function
|
// Main compaction function
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
const TURN_PREFIX_SUMMARIZATION_PROMPT = `You are performing a CONTEXT CHECKPOINT COMPACTION for a split turn.
|
const TURN_PREFIX_SUMMARIZATION_PROMPT = `This is the PREFIX of a turn that was too large to keep. The SUFFIX (recent work) is retained.
|
||||||
This is the PREFIX of a turn that was too large to keep in full. The SUFFIX (recent work) is being kept.
|
|
||||||
|
|
||||||
Create a handoff summary that captures:
|
Summarize the prefix to provide context for the retained suffix:
|
||||||
- What the user originally asked for in this turn
|
|
||||||
- Key decisions and progress made early in this turn
|
|
||||||
- Important context needed to understand the kept suffix
|
|
||||||
|
|
||||||
Be concise. Focus on information needed to understand the retained recent work.`;
|
## Original Request
|
||||||
|
[What did the user ask for in this turn?]
|
||||||
|
|
||||||
|
## Early Progress
|
||||||
|
- [Key decisions and work done in the prefix]
|
||||||
|
|
||||||
|
## Context for Suffix
|
||||||
|
- [Information needed to understand the retained recent work]
|
||||||
|
|
||||||
|
Be concise. Focus on what's needed to understand the kept suffix.`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate compaction and generate summary.
|
* Calculate compaction and generate summary.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue