-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(condense): unify UI/API histories; condense metadata; API history excludes condensed children #8512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…history excluding condensed children; tag UI condense_context
await this.overwriteApiConversationHistory(messages) | ||
|
||
// Merge condense metadata into API and UI histories (mark children and replace summary) | ||
const { condenseId = `c_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}` } = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the condenseContext() method, the code extracts a local condenseId from the result and then calls applyCondenseMetadataToHistories(result), which may generate its own condenseId. To ensure consistency, consider using the returned condenseId from applyCondenseMetadataToHistories instead of destructuring it from result separately.
* - Mark all prior messages (excluding the original first message) with condenseParent = condenseId | ||
* - Persist changes to disk | ||
*/ | ||
private async applyCondenseMetadataToHistories( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the applyCondenseMetadataToHistories() method, several casts are used (e.g. '(m as any).condenseParent') to check/update properties that are defined in the ClineMessage schema. Consider using proper type assertions to avoid 'as any'. Also, similar UI tagging logic (e.g. for condense_context messages at multiple locations) is duplicated; refactoring this into a shared helper would improve maintainability.
This comment was generated because it violated a code review rule: irule_tTqpIuNs8DV0QFGj.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing my own code again—truly the ouroboros of automation nibbling its tail a line at a time.
try { | ||
const idx = findLastIndex(this.clineMessages, (m) => m.type === "say" && m.say === "condense_context") | ||
if (idx !== -1) { | ||
;(this.clineMessages[idx] as any).condenseId = condenseId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] condenseId source of truth for UI tagging.
applyCondenseMetadataToHistories may synthesize a condenseId when result.condenseId is missing. To avoid a mismatch between persisted histories and the UI tag on condense_context, capture the returned condenseId and use it here.
;(this.clineMessages[idx] as any).condenseId = condenseId | |
// Merge condense metadata into API and UI histories (mark children and replace summary) | |
const { condenseId } = await this.applyCondenseMetadataToHistories(result) |
fixed #8295
Implements condenseId/condenseParent across UI and API histories. On condense, summary parent gets condenseId and condensed children are marked with condenseParent; first original message is preserved. API request assembly now filters out children (records with condenseParent). Adds tagging of condense_context UI rows.
Key changes:
Local targeted tests passed: core/condense, core/sliding-window, core/task suites.
Important
Introduces condense feature to unify UI/API histories by adding
condenseId
andcondenseParent
, filtering condensed children from API requests.condenseId
andcondenseParent
inClineMessage
schema inmessage.ts
.condenseParent
inTask.attemptApiRequest()
inTask.ts
.condenseId
toSummarizeResponse
inindex.ts
.summarizeConversation()
inindex.ts
now generatescondenseId
and attaches it to the summary.Task.applyCondenseMetadataToHistories()
inTask.ts
applies condense metadata to histories.ApiMessage
type inapiMessages.ts
to includecondenseId
andcondenseParent
.This description was created by
for 534afc5. You can customize this summary. It will automatically update as commits are pushed.