Skip to content

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

@sahilchouksey

Description

@sahilchouksey

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions