TypeError: undefined is not an object (evaluating 'toSummarize.at(-1).info') #1694

Closed
opened 2026-02-16 17:32:12 -05:00 by yindo · 3 comments
Owner

Originally created by @sahilchouksey on GitHub (Sep 12, 2025).

Originally assigned to: @thdxr on GitHub.

Description

A TypeError: undefined is not an object (evaluating 'toSummarize.at(-1).info') occurs during session summarization when attempting to create issue content.

Steps to Reproduce

  1. Trigger session summarization in scenarios where there are 0 or 1 messages after the last summary message.
  2. The error occurs at line 1826 in packages/opencode/src/session/index.ts when accessing toSummarize.at(-1).info.time.created.

Expected Behavior

Session summarization should handle cases with no messages to summarize gracefully without throwing an error.

Actual Behavior

The application throws a TypeError because toSummarize is an empty array, and at(-1) returns undefined.

Root Cause

The summarize function assumes toSummarize (a slice of messages) is non-empty, but it can be empty when msgs.length - start is 0 or 1, leading to an empty slice.

Environment

  • Platform: Linux
  • Opencode version: 0.7.3

Additional Context

This error prevents proper session compaction and interrupts user workflows

Originally created by @sahilchouksey on GitHub (Sep 12, 2025). Originally assigned to: @thdxr on GitHub. ### Description A `TypeError: undefined is not an object (evaluating 'toSummarize.at(-1).info')` occurs during session summarization when attempting to create issue content. ### Steps to Reproduce 1. Trigger session summarization in scenarios where there are 0 or 1 messages after the last summary message. 2. The error occurs at line 1826 in `packages/opencode/src/session/index.ts` when accessing `toSummarize.at(-1).info.time.created`. ### Expected Behavior Session summarization should handle cases with no messages to summarize gracefully without throwing an error. ### Actual Behavior The application throws a TypeError because `toSummarize` is an empty array, and `at(-1)` returns `undefined`. ### Root Cause The `summarize` function assumes `toSummarize` (a slice of messages) is non-empty, but it can be empty when `msgs.length - start` is 0 or 1, leading to an empty slice. ### Environment - Platform: Linux - Opencode version: 0.7.3 ### Additional Context This error prevents proper session compaction and interrupts user workflows
yindo closed this issue 2026-02-16 17:32:12 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 12, 2025):

This issue might be a duplicate or related to existing issues. Please check:

  • #2234: Issues with compact functionality causing conversation context problems
  • #970: Edge-case in tool calls for auto-compacting, which mentions context/compaction issues
  • #606: Problems with compact command interruption (closed, but related to compaction functionality)

The error you're experiencing seems to be in the summarization logic during session compaction. While not exact duplicates, these issues all relate to problems with the compaction/summarization system.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Sep 12, 2025): This issue might be a duplicate or related to existing issues. Please check: - #2234: Issues with compact functionality causing conversation context problems - #970: Edge-case in tool calls for auto-compacting, which mentions context/compaction issues - #606: Problems with compact command interruption (closed, but related to compaction functionality) The error you're experiencing seems to be in the summarization logic during session compaction. While not exact duplicates, these issues all relate to problems with the compaction/summarization system. Feel free to ignore if none of these address your specific case.
Author
Owner

@vldF commented on GitHub (Sep 12, 2025):

I have this too

@vldF commented on GitHub (Sep 12, 2025): I have this too
Author
Owner

@thdxr commented on GitHub (Sep 12, 2025):

should be fixed now

@thdxr commented on GitHub (Sep 12, 2025): should be fixed now
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1694