Skip to content

fix(background-agent): prevent formatForCompaction crash on undefined description#1997

Open
FFFergie wants to merge 1 commit intocode-yeongyu:devfrom
FFFergie:fix/1991-task-history-description-null-guard
Open

fix(background-agent): prevent formatForCompaction crash on undefined description#1997
FFFergie wants to merge 1 commit intocode-yeongyu:devfrom
FFFergie:fix/1991-task-history-description-null-guard

Conversation

@FFFergie
Copy link

@FFFergie FFFergie commented Feb 20, 2026

Summary

  • Prevent TaskHistory.formatForCompaction() from crashing when a task entry has an undefined description.
  • Keep compaction output formatting stable by defaulting missing descriptions to an empty string.
  • Add a regression test that reproduces the undefined-description scenario.

Changes

  • Updated src/features/background-agent/task-history.ts:
    • Guarded description sanitization with (e.description ?? "") before .replace().
  • Updated src/features/background-agent/task-history.test.ts:
    • Added handles entries with undefined description without throwing test case.

Testing

bun test src/features/background-agent/task-history.test.ts
bun run typecheck
bun run build

Related Issues

Closes #1991


Summary by cubic

Fix crash when formatting task history entries with undefined descriptions by treating them as empty strings. Adds a regression test; addresses #1991.

Written for commit 59991a4. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: cubic found no issues; change adds guard for undefined description preventing crash with regression tests included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] TypeError: Cannot read properties of undefined (reading 'replace') in formatForCompaction when dynamic_context_pruning enabled

1 participant