Skip to content

Conversation

@dzianisv
Copy link
Owner

@dzianisv dzianisv commented Feb 9, 2026

Summary

  • Fix reflection plugin triggering in Plan Mode (checks system messages now)
  • Add support for custom reflection prompts via ./reflection.md file
  • Improve message ID tracking to handle compression correctly

Changes

1. Fix Plan Mode Detection

Problem: Reflection plugin was triggering during Plan Mode sessions, interrupting the agent's workflow.

Root Cause: The isPlanMode() function only checked user messages for "plan mode" keywords. It missed the system/developer messages that OpenCode injects to indicate Plan Mode is active.

Solution:

  • Updated isPlanMode() to scan system and developer role messages
  • Checks for indicators: "Plan Mode", "plan mode ACTIVE", "read-only mode"
  • Added debug logging when Plan Mode is detected

2. Add Custom Reflection Prompt Support

Feature: Allow projects to customize the reflection questions.

Implementation:

  • Added loadReflectionPrompt(directory) function
  • Reads ./reflection.md from working directory
  • Falls back to hardcoded 4-question prompt if file doesn't exist
  • Uses Node.js fs/promises API for async file reading

Usage:

# In your project directory
echo "Did you complete the task? What's remaining?" > reflection.md

3. Message ID Tracking Improvements (previous commits)

  • Use message IDs instead of message count to track reflection state
  • Handles message compression correctly (when OpenCode merges consecutive messages)
  • Allows recursive reflection for multi-step tasks

Testing

  • ✅ TypeScript typecheck passes
  • ✅ All unit tests pass
  • ✅ Plugin loads without errors
  • ✅ Deployed to ~/.config/opencode/plugin/reflection-static.ts

Files Changed

  • reflection-static.ts - Main plugin file with Plan Mode fix and custom prompt support
  • github.ts - New GitHub issue integration plugin
  • telegram.ts - Whisper endpoint fixes
  • Various test files - Consolidated and improved test coverage

Related Issues

Fixes the issue where reflection plugin interrupted Plan Mode sessions.

dzianisv and others added 5 commits February 8, 2026 17:57
…ction.md support

- Fix Plan Mode detection to check system/developer messages (not just user messages)
- Add support for custom reflection prompt via ./reflection.md file
- Falls back to default 4-question prompt if reflection.md not found
- Fixes issue where reflection triggered in Plan Mode and interrupted agent workflow
@dzianisv dzianisv merged commit 0473458 into main Feb 9, 2026
2 checks passed
@dzianisv dzianisv deleted the feat/reflection-static-plugin branch February 9, 2026 22:05
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.

1 participant