Skip to content

[FEATURE]: Code quality gets worse as conversations get longer — compaction loses context, no automatic verification after edits #30811

Closed

Description

Description

Over a long conversation, the AI makes more and more mistakes. The code quality gets worse, not better. This happens because of five problems in how opencode works:

1. Compaction throws away context. When the chat gets too long, opencode summarizes old messages. Only the last 2 turns survive. Everything else (file contents, error messages, what files you changed) is replaced by a short summary. After 3-4 compactions, the AI doesn't remember what it was doing.

2. No one checks if the code works. After the AI edits a file, nothing runs tsc or npm test automatically. The system prompt says "run lint and typecheck" but that's just a suggestion. The AI might skip it, forget it, or not understand the error output.

3. No safety checks when writing files. The edit tool just writes the file. It doesn't check if imports are broken, if the syntax is valid, or if tests still pass.

4. Edit matching is too strict. The edit tool requires an exact match of the old text. If it doesn't match, the AI has to guess what went wrong. There is no fuzzy matching to handle small differences in whitespace or formatting.

5. A downward spiral. As the conversation gets longer, compaction throws away more context. With less context, the AI guesses more and makes more errors. More errors mean more edits, which make the conversation even longer, which triggers more compaction.

Suggested Fix

Three changes would help, ordered from easiest to hardest:

A. Check the code after every edit. After the AI writes a file, run tsc --noEmit (or the project's equivalent) automatically. If there are type errors, show them to the AI so it can fix them. I built a small test of this — it adds about 1 second per edit but catches most broken imports and type errors immediately.

B. Keep important information during compaction. Instead of just keeping the last 2 chat turns, also keep: the last error message, the last test output, and the content of files the AI recently read. This way the AI doesn't forget what it discovered earlier.

C. A real quality pipeline. Eventually: format the code, run lint, check types, run tests — all automatically after each change. Give the AI the results in a structured way.

I've filed specific bugs about several of these problems already: #30781 (edit error messages don't tell the AI to re-read), #30805 (compaction fires too late), #30806 (compaction has state cleanup bugs), #30807 (pruning has a loop bug that skips old tools).

OpenCode version

main

Steps to reproduce

  • I have verified this feature I'm about to request hasn't been suggested before.
  1. Start a conversation in a project with TypeScript
  2. Ask the AI to make several changes across multiple files
  3. Let the conversation grow long enough for compaction to trigger (5-10+ turns)
  4. Ask the AI to make another change
  5. Notice it starts making mistakes it didn't make earlier — wrong file paths, broken imports, syntax errors
  6. Each compaction cycle makes this worse

Screenshot and/or share link

Operating System

Terminal

Activity

  1. github-actions commented on Jun 4, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The title uses [RFC]: which is not one of the supported issue types. Please use one of the three required templates: Bug Report, Feature Request (title must start with [FEATURE]:), or Question.
    • If this is a Feature Request, the title should start with [FEATURE]: and the template's verification checkbox must be checked.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of or closely related to existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions commented on Jun 4, 2026

    @github-actions
    Contributor

    Thank you for updating the issue. Unfortunately, it is still not compliant with our contributing guidelines.

    What still needs to be fixed:

    1. Title format: The title uses [RFC]: which is not a supported issue type. If this is a Feature Request, the title must start with [FEATURE]:.

    2. AI-generated content: The issue body contains what appears to be AI-generated walls of text — multiple detailed implementation proposals with exact TypeScript code snippets, line-by-line file references, and structured cost/impact tables. We do not accept AI-generated content of this kind. Please rewrite the issue in your own words, describing the problem you're experiencing and what you'd like to see changed.

    Please edit the issue to address the above. Keep the needs:compliance label in place until it is resolved.

  3. github-actions commented on Jun 4, 2026

    @github-actions
    Contributor

    Thank you for updating the issue. Unfortunately, it is still not compliant with our contributing guidelines.

    What still needs to be fixed:

    1. Title format: The title still uses [RFC]: which is not a supported issue type. Please change it to match one of the three required templates:

      • Bug Report (no special prefix required)
      • Feature Request (title must start with [FEATURE]:)
      • Question (no special prefix required)
    2. AI-generated content: The issue body still contains what appears to be AI-generated walls of text — multiple lengthy implementation proposals with exact TypeScript code snippets, precise line-number references, structured cost/impact tables, PoC timing benchmarks, and full configuration JSON examples. This has not been addressed since the last compliance comment. Please rewrite the issue in your own words, focusing on the problem you're experiencing and what you'd like to see changed.

    Please edit the issue to address both of the above. The needs:compliance label will remain until these are resolved.

  4. github-actions commented on Jun 4, 2026

    @github-actions
    Contributor

    Thank you for updating the issue. Unfortunately, it is still not compliant with our contributing guidelines.

    What still needs to be fixed:

    1. Title format: The title still uses [RFC]: which is not a supported issue type. Please change it to one of the three required templates:

      • Bug Report (no special prefix required)
      • Feature Request (title must start with [FEATURE]:)
      • Question (no special prefix required)
    2. AI-generated content: The issue body still contains what appears to be AI-generated walls of text — multiple lengthy implementation proposals with exact TypeScript code snippets, precise line-number references, structured cost/impact tables, PoC timing benchmarks, and full configuration JSON examples. This has been flagged in previous compliance comments and has not been addressed. Please rewrite the issue in your own words, concisely describing the problem you're experiencing and what you'd like to see changed.

    The needs:compliance label will remain until both of the above are resolved.

  5. github-actions commented on Jun 4, 2026

    @github-actions
    Contributor

    Thank you for updating the issue — the title format and content are much improved. However, one required field is still missing.

    What still needs to be fixed:

    • Verification checkbox: The Feature Request template requires you to confirm: "I have verified this feature I'm about to request hasn't been suggested before." This checkbox is missing from the issue body. Please edit the issue and add it (checked).

    Once that's added, the issue will be compliant.

  6. github-actions commented on Jun 4, 2026

    @github-actions
    Contributor

    Thank you for updating the issue — it now meets our contributing guidelines. The title, verification checkbox, and description all look good. We appreciate you taking the time to revise it!

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions