Skip to content

Fix OpenCode leaked think normalization#457

Merged
danshapiro merged 1 commit into
mainfrom
fix/opencode-think-normalization
Jun 21, 2026
Merged

Fix OpenCode leaked think normalization#457
danshapiro merged 1 commit into
mainfrom
fix/opencode-think-normalization

Conversation

@danshapiro

Copy link
Copy Markdown
Owner

Preserve leaked OpenCode/Kimi think content as thinking transcript items instead of stripping it from assistant text. Handle balanced tags, malformed leading closer markers, marker-only parts, unterminated open tags, and role-missing OpenCode messages while preserving user-authored text.

Changes:

  • Replaces stripThinkTags with itemsFromAssistantTextPart that segments think-tag content into visible thinking items
  • Adds NormalizedTextSegment type, normalizeBalancedThinkTags, segmentsToItems helpers
  • Changes itemFromPart to return FreshAgentTranscriptItem[] (flatMap) and accept followedByTool param
  • Adds computeToolAfterByPartIndex and textSummaryFromItems helpers
  • 4 new tests covering balanced, malformed, unterminated, and dangling think tags

Rebase notes: Resolved conflict in normalizeOpencodeTurn — kept main's role-less message rejection policy (null return) while applying the think-tag normalization improvements. Updated one branch test to match main's role-less rejection behavior.

Kata: 0yza

Preserve leaked OpenCode/Kimi think content as thinking transcript items instead of stripping it from assistant text. Handle balanced tags, malformed leading closer markers, marker-only parts, unterminated open tags, and role-missing OpenCode messages while preserving user-authored text.
@danshapiro danshapiro merged commit d6b4237 into main Jun 21, 2026
1 check passed
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.

2 participants