Skip to content

fix: filter system-reminder messages in OpenCode transcript parser#671

Merged
peyton-alt merged 2 commits intoentireio:mainfrom
mvanhorn:osc/564-fix-opencode-system-reminder
Mar 21, 2026
Merged

fix: filter system-reminder messages in OpenCode transcript parser#671
peyton-alt merged 2 commits intoentireio:mainfrom
mvanhorn:osc/564-fix-opencode-system-reminder

Conversation

@mvanhorn
Copy link
Contributor

Summary

Fixes #564

Filters out <system-reminder> messages that are injected by tools like oh-my-opencode with user role. These messages were incorrectly counted as user prompts in attribution and checkpoint data.

Changes

  • cmd/entire/cli/agent/opencode/transcript.go - Added isSystemReminderOnly() and stripSystemReminders() functions; updated ExtractAllUserPrompts() to skip or strip system-reminder content
  • cmd/entire/cli/agent/opencode/transcript_test.go - Added 6 test functions covering pure system-reminder messages, mixed content, and whitespace handling

Approach

Content-based heuristic: messages entirely wrapped in <system-reminder>...</system-reminder> tags are skipped. Mixed messages have the reminder tags stripped. This is the best approach given that OpenCode doesn't expose x-initiator metadata.

Test plan

  • System-reminder-only messages excluded from prompts
  • Mixed messages have reminder sections stripped
  • Normal user messages unaffected
  • gofmt and go vet clean

This contribution was developed with AI assistance (Claude Code).

mvanhorn and others added 2 commits March 20, 2026 17:12
Messages sent with role "user" that consist entirely of
<system-reminder>...</system-reminder> tags (injected by oh-my-opencode
for multi-agent orchestration) are now excluded from
ExtractAllUserPrompts. Mixed messages have system-reminder sections
stripped, preserving the actual user content.

Closes entireio#564

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rewrite isSystemReminderOnly to delegate to stripSystemReminders,
fixing a false positive where content like
<system-reminder>a</system-reminder>real<system-reminder>b</system-reminder>
was incorrectly classified as system-reminder-only (HasPrefix+HasSuffix
matched but real user content existed between the blocks).

- Guard the empty-string edge case (empty is not a system-reminder)
- Consolidate two separate const declarations into one block
- Add test case covering the multi-block false-positive scenario

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@peyton-alt peyton-alt force-pushed the osc/564-fix-opencode-system-reminder branch from e9daf9a to b7903c9 Compare March 21, 2026 00:15
@peyton-alt peyton-alt enabled auto-merge (squash) March 21, 2026 00:24
@peyton-alt peyton-alt merged commit 617c714 into entireio:main Mar 21, 2026
3 checks passed
@mvanhorn
Copy link
Contributor Author

Thanks for the review!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[OpenCode] <system-reminder> messages from oh-my-opencode is tracked as user message instead of opencode

3 participants