Skip to content

feat: add a new mode (learn mode) - #25

Merged
MichaelYeh507 merged 28 commits into
mainfrom
myeh2/add-new-mode
Oct 7, 2026
Merged

MichaelYeh507 merged 28 commits into
mainfrom
myeh2/add-new-mode

Conversation

@MichaelYeh507

@MichaelYeh507 MichaelYeh507 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #10

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a third primary agent, Learn, next to Build and Plan (Tab cycles Build → Learn → Plan; Learn is pinned green).
In Learn mode, every file edit is held until the user answers a comprehension question about the change:

  • Before an edit, write, or apply_patch call is applied, a small model call writes one question about the diff, and the user answers it in the TUI.
  • A second model call grades the answer. If it passes, the edit applies.
  • If it fails, the user sees feedback and gets a new question. Retries are unlimited, but each new question is generated from the last three failed attempts and is asked to break the concept into a smaller, more concrete step.
  • Dismissing the question rejects the edit and stops the turn.
  • A multi-file apply_patch (used by GPT models) gets one combined question.
  • If the check can't run (for example, the change is too large to quiz on, or the model returns malformed output), the edit is rejected with feedback telling the model to make a smaller edit, instead of the tool crashing.

The edit tools are the only gated path, so Learn's system reminder tells the model never to change files through bash or a subagent. This is a prompt-level guard, the same approach plan mode uses. Build and Plan are unchanged.

How did you verify your code works?

I added unit tests for each part of the feature: the Learn agent definition and its reminder, question generation (including how earlier failed attempts shape the next question and how question marks inside code are handled), answer grading (including JSON the model wraps in a code block), the retry loop, the check in the session tools, and the combined question for multi-file apply_patch edits. bun typecheck passes in packages/opencode and packages/core, and CI is green. I also ran it locally with bun dev: I switched to Learn, asked it to edit the README, got a comprehension question first, and the edit was only written after I answered it.

Screenshots / recordings

learn_mode_green image

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@MichaelYeh507 MichaelYeh507 changed the title Myeh2/add new mode feat: add a new mode (mock learn) Sep 23, 2026
@MichaelYeh507 MichaelYeh507 changed the title feat: add a new mode (mock learn) feat: add a new mode (mock learn mode) Sep 23, 2026
@MichaelYeh507 MichaelYeh507 changed the title feat: add a new mode (mock learn mode) feat: add a new mode (learn mode) Oct 5, 2026
@drek2991

drek2991 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Needs a little more clarification on the testing happening; perhaps further integration tests and even maybe going into E2E tests.

@MichaelYeh507
MichaelYeh507 merged commit 8b2c5f4 into main Oct 7, 2026
7 of 9 checks 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.

create and be able to switch to a new mode

3 participants