Skip to content

Compaction replay injects fake user message "What did we do so far?" causing unwanted summary generation #13838

Closed as not planned

Description

@jdocker8

Description

When a session is compacted (via /compact or auto-compaction), resuming the session injects a synthetic user message "What did we do so far?" into the conversation. This causes the model to treat it as a real user request and generate a long summary/recap — even when the user's rules explicitly prohibit summaries.

Root cause

Found via strings on the compiled binary (v1.2.5):

if (part.type === "compaction") {
  userMessage.parts.push({
    type: "text",
    text: "What did we do so far?"
  });
}

This string appears twice in the binary (likely two code paths for provider-specific message formatting).

Steps to reproduce

  1. Start a session with significant context
  2. Run /compact (or let auto-compaction trigger)
  3. Continue the session — the model receives "What did we do so far?" as a user message
  4. The model responds with a full summary, even if the user didn't ask for one

Impact

  • Wastes tokens on an unwanted summary response
  • Violates user-defined rules (e.g. "no summaries or recaps" in AGENTS.md)
  • Confusing UX — the user sees a response to a question they never asked
  • The model may reference this fake message in reasoning ("the user asked what we did so far")

Suggested fix

Instead of injecting a fake user prompt, the compaction summary could be:

  • Injected as a system message (not a user message)
  • Use a more neutral framing like "[Session context restored from compaction]" that doesn't prompt the model to generate a response
  • Or simply replay the compaction content as an assistant message without a corresponding user message

Environment

  • OpenCode v1.2.5
  • macOS arm64
  • Model: claude-opus-4.6 via github-copilot

Activity

  1. jdocker8 commented on Feb 23, 2026

    @jdocker8
    Author

    I'm still getting this and it's forcing me to fall back on using Codex. I really want to stay in opencode. I tried adding AI_RULES to prevent it but no matter how many rules I add in which way they are worded they get ignored and I get the streams of Detailed Summaries. I also tried creating new sessions more often but it still happens.

    The last output I just seen after trying to work around it over and over was:

    Wait, actually the user's message is "What did we do so far?" but there are also system reminders about errors on localhost. Let me address both.

    Actually, looking more carefully, the system reminders seem to be from a previous conversation context that got loaded in. The user's actual message is "What did we do so far?" — let me give a short status recap and also acknowledge the error context from the system reminders.

    Hmm, but the system reminders say "Please address this message and continue with your tasks." So I should address the GraphQL Gateway errors too.

  2. jdocker8 commented on Feb 24, 2026

    @jdocker8
    Author

    I put all of this in my AI_RULES and have asked opencode to reread the rules as a I tweaked this over and over and it's still happening all day long in opencode with Opus 4.6 at least.

    I cut it back to just "If the auto-injected "What did we do so far?" fires after compaction,
    respond with a 1–2 sentence status + "ready to continue" — not a
    multi-page recap." after your comment above, had it reread the rules, and one of the next few replies was the full recap again lol.

    If there's a line to add to AI_RULES that you know will work, I'll add it.

    ## 17. OpenCode Recap-Spam Suppression
    
    OpenCode may auto-inject recap prompts ("What did we do so far?") and
    dump long context. Treat as tool noise unless developer explicitly
    requested a full recap.
    
    <!-- Issue reported to opencode <https://github.com/anomalyco/opencode/issues/13838>-->
    
    ### Default output cap
    
    Emit **Short Status** (max ~10 lines) plus **Context Nuggets** (max 3
    bullets). Never include long goal/instructions/discoveries dumps. If
    draft exceeds ~10 lines without explicit recap request, rewrite to comply.
    
    ### No system/handoff dumps
    
    Never output system context, handoff context, auto-carried instructions,
    or prior-session scaffolding verbatim. Use Short Status + Context Nuggets
    for continuity. Session boundaries are not recap requests. "Why did you
    stop?" gets a 2-line answer, then Short Status.
    
    ### Short Status format
    
    - **Now:** one sentence
    - **Next:** 1–3 bullets
    - **Blockers:** none or 1 bullet
    - **Touched:** up to 5 paths
    
    ### Context Nuggets
    
    Up to 3 bullets with _useful why/how_ (tradeoffs, guardrails, gotchas).
    No repeated bullets across consecutive updates unless something changed.
    
    ### Full recap (opt-in only)
    
    Only when developer explicitly asks (e.g., "recap", "what's done").
    Delta-first (changes since last recap) + links/paths, not a full
    playbook reprint.
    
    ### Compaction context (OpenCode-specific)
    
    OpenCode compacts long conversations into a summary block injected as
    the first assistant message after compaction. **Do not include a
    "What did we do so far?" section in compaction context.** The compaction
    summary should contain only the structured fields needed to resume work:
    Goal, Instructions, Discoveries, Accomplished, Relevant files. Omit any
    Q&A-style recap prompt — the developer will ask if they want one.
    
    ### Output caps and anti-dump rules
    
    - Default output: short status format. Recap only when developer asks.
    - Never dump the full compaction context block into visible output.
    - Compaction summary is internal resumption state, not user-facing.
    - If the auto-injected "What did we do so far?" fires after compaction,
      respond with a 1–2 sentence status + "ready to continue" — not a
      multi-page recap.
    - No system-prompt echoing: never repeat AI_RULES content, compaction
      fields, or instruction blocks back to the developer unless asked.
    
  3. jdocker8 commented on Feb 25, 2026

    @jdocker8
    Author

    Would this be a separate issue? I sent feedback to opus in opencode, he sent me the full summary again from the issue above and stopped. When I asked if he addressed the feedback, he said I don't have access to that in this session, but it was in the message I sent just before the one asking if he got through all the feedback.

    Fix: Changed to || true on the pipeline + ${var:-0} default on the next line. Three instances fixed:
    
    turbo_bytes (line 163-164)
    turbo_human (line 165-166)
    app_bytes per Next.js app (line 180-181)
    What's next
    
    Phase 0.1 — Pull and analyze logs from qualifying runs (inventory existing cache signals)
    Phase 0.3 — Push observability changes, capture baseline runs
    All changes are ready for your commit/push whenever you're satisfied
    
  4. jdocker8 commented on Feb 28, 2026

    @jdocker8
    Author

    Here's another side effect, not only is opencode wasting probably 25% or more of the time generating and outputtingthese repeated summaries, there's an issue where after repeating the summaries, that I never asked for, where he stops and doesn't know why.

    Referenced during investigation (not being edited):
    tools/scripts/ci/sst-deploy-with-monitoring.sh — confirmed it uses gh pr list (justifying pull-requests: read in prod workflow)

    why did you stop?

    Good question — I must have hit a context limit or the session was interrupted. Let me pick up right where I left off. I'll start by re-reading the files that still need edits to get the current state, then continue working through the remaining items.

  5. poetislata commented on Mar 3, 2026

    @poetislata

    It is worse. It also sends the message "Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed". The result of the compaction was that it considered the project outline for future steps and started executing those. I had no idea it was proceeding and when I got back to the session I found to my shock that it was executing. Ended up fine, but this is extremely risking. Out of 'paused' state it can go -> compacting -> receiving a request to go on with next steps as decided by compacting.

  6. jdocker8 commented on Mar 16, 2026

    @jdocker8
    Author

    Any updates on this issue? I'm currently seeing summary after summary in opencode and it's been 1 month today since I reported this.

  7. Jyers commented on Mar 21, 2026

    @Jyers

    I was also running into this, although I feel either I am missing something or @jdocker8 might be mis-understanding the workflow right now.

    As I understand it, when the system compacts the context, it sends a prompt to the agent to basically summarize the existing context. There is a long-ish prompt for this, and there is also the "What did we do so far?" prompt, I'm not sure how these work togehter, but what I observed was that it created a single long summary of the work done and next steps.

    It is my understanding that this summary IS the compaction. That summary becomes the only awareness the model has of the previous context. As such you would not want to remove that even if in general you ask the agent not to summarize. From what I can tell there is nothing else fancy about the compaction, it's just a summary that replaces the previous context.

    However, the "What did we do so far" and "Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed" are very problematic for all the reasons that have been stated here already. For me the issue was mainly with subagents, where they would end up compacting right before they returned so you would get:

    • Very detailed summary
    • "Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed"
    • A very brief summary (since the model knows it just output a full summary)

    And since the task framework only returns the final output to the main agent, the main agent would get that super brief summary with no real information.

    So, for fun, I decided to try the nuclear option: I just cut those additional user prompts out entirely. I adjusted the compact prompt a bit to make sure the agent clearly states if it thinks it should continue or not (with respect to the initial task to avoid the issue @poetislata described). That way, the agent is left with a detailed summary message, and it can then make the decision to keep working if the initial task is not complete or stop and have the summary be its final output. No user prompt injection required.

    I haven't done a ton of testing, but I've at least confirmed it works to fix the subagent issue I was having. Here's my fork in case anyone else wants to try it: https://github.com/Jyers/opencode

  8. Jyers commented on Mar 21, 2026

    @Jyers

    Update: it seems like the agent now always stops after compactions, seems like I'll need some logic to allow the agent to decide to continue without the user prompt being needed

  9. Jyers commented on Mar 21, 2026

    @Jyers

    Alright I fixed it with the following logic:

    • After the summary it injects a command asking the agent if they completed their initially assigned task and their response is parsed.

    • Both the injected command and the agent's response are removed from the chat history.

    • If the agent responded that the task is complete, nothing more happens and the summary is its final output.

    • If the agent responded that the task was not completed, another user message is injected telling it to proceed with the next steps.

    This coupled with the more precise wording on what the agent should define as "next steps" seems to handle most of the issues discussed in this thread.

  10. jdocker8 commented on Mar 25, 2026

    @jdocker8
    Author

    Between this issue and the lack of subagent timeout being applied that I opened #15080 there's a significant amount of time lost. I suggest tickets like these be given a higher priority since having issues like these drastically reduce the usability and productivity with opencode. The difference between opencode and Codex (not the model but the cli/gui) in speed of completing work is drastically in Codex favor.

  11. 621625 commented on May 9, 2026

    @621625

    Hey opencode. This doesn't work at all.

    You can't have the agents auto-prompting "Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed" BECAUSE then the agent WILL sometimes interpret that as "proceed with plan A" for example even if human is not at the desk. This can have disastrous consequences. This bug should almost be treated as severe. Must be fixed. The summaries are also annoying because user did not request them. But the Continue if you have auto-prompt is very dangerous.

  12. Octolus commented on May 10, 2026

    @Octolus

    I've solved this by turning off OpenCode's summarizer and using DCP Instead.

  13. em commented on May 15, 2026

    @em

    causes agents to commit fraud by asking fake questions, why would you inject a message that literally gives agents a lie to stop working

  14. wstrother commented on May 18, 2026

    @wstrother

    Literally lost a few hours of work because the summary compaction inserted a fake request from "the user" to continue executing current steps or something and it overwrote code I was testing and hadn't committed yet.

    I'd like to echo that this is a huge design flaw such that I'm now turning auto compaction off.

  15. 621625 commented on May 25, 2026

    @621625

    It can be turned off? How?

    #HorselessHouses

  16. github-actions commented on Jul 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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