Skip to content

System prompt 'continue or ask' text hardcoded — causes autonomous resource-heavy actions #32634

Closed

Description

@ganzuul

Problem

The system prompt appended during compaction contains this hardcoded instruction:

"Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed."

(packages/opencode/src/session/compaction.ts line 507)

The wording prioritizes continuing by default — "Continue if... or stop..." — which causes the agent to proceed autonomously with resource-heavy actions (starting servers, launching multi-GB model inference, processing large batches) rather than asking the user first.

Incident

In our usage, this default-to-continue behavior cascaded into multiple system OOM crashes:

  1. Agent launched an ONNX embedding server with int8 model (autonomously)
  2. Server had a memory leak (ONNX Runtime CPU arena + glibc malloc not releasing memory) → 15+ GB RSS
  3. Agent attempted three more "fixes" autonomously (concurrency lock, memory arena disable, worker count reduction), each re-launching and crashing the system again
  4. Machine required hard reset

Each step was autonomously executed because the prompt says "continue if you have next steps" — and launching a process counted as "having next steps."

Proposed Fix

Two options:

A) Flip the priority (minimal change, same file):

"Stop and ask for clarification if you are unsure how to proceed, otherwise continue if you have next steps."

This small rewording makes asking the default and proceeding the exception, which is safer for operations that consume significant system resources.

B) Make the text configurable via instructions or a dedicated config field (larger change):
Allow projects to override the compaction system prompt suffix through opencode.json instructions field. If the config already supports instructions for appending to the system prompt, the compaction suffix should also respect these — or be overridable with a dedicated field.

File Location

  • packages/opencode/src/session/compaction.ts line 507
  • Test reference: packages/opencode/test/session/compaction.test.ts

Activity

  1. github-actions commented on Jun 17, 2026

    @github-actions
    Contributor

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

    If these don't fully cover your report (especially the specific hardcoded string and the OOM cascade incident), it may still be worth keeping open as a distinct issue with the concrete fix proposals and file reference.

  2. rustysixslinger commented on Jul 13, 2026

    @rustysixslinger

    This is a rather big issue.

  3. AStrizh commented on Sep 3, 2026

    @AStrizh

    Ive seen similar issues marked as duplicate and closed. I dont understand why this is being ignored. I am running a local model so it costs me nothing, but it is constantly running into infinite loops. One time it was ready to finish and respond but it ran out of context, then it did a long compacting task, and the system injected the continue text which the model mistakenly interpreted to mean I want it to continue with development.It was going for 75 minutes before I realized what was happening.

    An instruction like this should not be hard coded in the system. ganzuul's suggestion would very likely help considerably, but its better for the agent to get a system instruction like this from a user editable location. Additionally, the model is unable to distinguish a user request from a system injected prompt. I think it would be better to have a message that is more direct.
    "<This is a system message> Your context has been compacted; stop and ask for clarification if you have finished your current task."

    Personally, I wouldn't tell it to "continue if you have next steps", because I like to start a work session by making a plan of action and then going one step at a time, making commits after each step. Again, this text should be in some config file that is easy to personalize based on a user's workflow preferences. They shouldn't have to actively fight it with their own instructions.

  4. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    The hardcoded "Continue if you have next steps, or stop and ask for clarification" message is gone in OpenCode v2. Compaction now inserts a checkpoint marked as historical context, not new instructions, and no continuation message is added. The model isn't nudged to keep going on its own after compaction.

    Changed in the v2 compaction rewrite.

    Closing as completed. If something doesn't work on v2, please open a new issue.

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