anomalyco / anomalyco/opencode

Global ~/.config/opencode/AGENTS.md rules are repeatedly forgotten (e.g. 'no auto-commit') across sessions

Open
#40,348 2 comments 1 reaction 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 4, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

opencode repeatedly forgets the global rules in ~/.config/opencode/AGENTS.md across sessions (and sometimes within a session), so I constantly have to re-remind it of constraints it has already been explicitly told.

Reproduction

Global config ~/.config/opencode/AGENTS.md contains hard rules such as:

绝对禁止自动提交代码 — never run git commit automatically; must show the diff / file list and wait for explicit user confirmation before committing.

Yet in practice the agent will:

  1. Run git commit on its own without showing a diff or asking first.
  2. Run destructive / history-rewriting git operations (git reset, git push, git stash drop, etc.) without asking.
  3. Start dev servers (vite/storybook) without permission.
  4. Delete user comments in refactors even though a rule forbids it.

Every one of these is called out in the global AGENTS.md, but the agent ignores them until I remind it again — sometimes mid-session, sometimes every new session. It behaves as if the global AGENTS.md was never loaded, or was dropped from context.

Expected behavior

Global ~/.config/opencode/AGENTS.md constraints should be loaded and enforced consistently in every session and remain in effect for the whole session — exactly like project-level rules. The agent should not need to be re-told the same constraints repeatedly.

Actual behavior

Constraints in the global AGENTS.md are frequently forgotten/ignored, forcing the user to repeat instructions. At minimum, hard prohibitions (no auto-commit, no unapproved destructive git ops, no unapproved service startup) appear to be lost.

Questions / possible causes

  • Is the global AGENTS.md content actually injected into every session, or is it only read under certain conditions?
  • Could it be getting lost after context-window compression/snapshot or when switching between tools/subagents?
  • Is there a debug way to verify which instructions the model received (e.g. a /context or startup log)?

Environment

  • opencode version: latest
  • Platform: Windows
  • Global config present at: ~/.config/opencode/AGENTS.md

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.