Skip to content

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Oct 4, 2025

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 and condenseParent, filtering condensed children from API requests.

  • Behavior:
    • Implements condenseId and condenseParent in ClineMessage schema in message.ts.
    • Filters out messages with condenseParent in Task.attemptApiRequest() in Task.ts.
    • Adds condenseId to SummarizeResponse in index.ts.
  • Functions:
    • summarizeConversation() in index.ts now generates condenseId and attaches it to the summary.
    • Task.applyCondenseMetadataToHistories() in Task.ts applies condense metadata to histories.
  • Misc:
    • Extends ApiMessage type in apiMessages.ts to include condenseId and condenseParent.

This description was created by Ellipsis for 534afc5. You can customize this summary. It will automatically update as commits are pushed.

…history excluding condensed children; tag UI condense_context
@roomote roomote bot requested review from mrubens, cte and jr as code owners October 4, 2025 20:25
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Oct 4, 2025
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)}` } =
Copy link

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(
Copy link

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.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 4, 2025
Copy link
Author

@roomote roomote bot left a 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
Copy link
Author

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.

Suggested change
;(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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

[BUG] Rewind after manual condense keeps only initial + new message
2 participants