Skip to content

[FEATURE]: optional runtime enforcement of edit tool's read-before-edit precondition #27901

Closed as not planned

Description

@haabe

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

The edit tool's description text says:

"You must use your Read tool at least once in the conversation
before editing. This tool will error if you attempt an edit
without reading the file."

Runtime test on opencode 1.15.1 shows the string lives in the
LLM-facing tool schema only. The executable code path does not
enforce the precondition. A clean edit succeeded on a fresh session
with no prior read of the target file (Version: 0.23.23 → 0.23.24 applied; no error, no warning).

Fine as a design choice. The description text behaves as a
behavioural nudge to capable models. But the wording "This tool
will error if you attempt an edit without reading the file" is
descriptive-as-asserted-fact, not "the model should read first." A
4B or 8B local model that ignores the instruction will edit
happily, and frameworks relying on the precondition for safety
properties (preventing stale-state edits, say) will silently
no-op.

The feature request: ship the precondition as a configurable
runtime check — e.g. a config flag tools.edit.require_prior_read
— that refuses edits without a recent read on the same path in
the current session. This brings parity with Claude Code, where
the precondition is structurally enforced. Default-off is
acceptable; frameworks that depend on it can opt in.

A cheaper alternative the maintainers might prefer: just soften
the docs from "will error" to "should read first" so framework
authors don't misread the schema string as a runtime guarantee.
That's not a feature, that's a docs fix; happy to file separately
as a Bug Report if preferred. The feature ask is the configurable
runtime check.

Verified 2026-05-16. Full reproduction context:
https://github.com/haabe/mycelium/blob/main/docs/receipts/cases/2026-05-16-opencode-phase1-runtime.md

Activity

  1. github-actions commented on May 16, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. This issue presents both a clarification/documentation fix and a feature request, but it doesn't use one of the required templates: Bug Report, Feature Request (title must start with [FEATURE]:), or Question.
    • If this is a feature request (e.g., adding runtime enforcement via a config flag), please reopen/edit with the Feature Request template and a title starting with [FEATURE]:.
    • If this is a documentation bug (the tool description says "will error" but doesn't), please use the Bug Report template and include reproduction steps.

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

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

  2. changed the title [-]Clarification or feature: edit tool's "must Read first" precondition is prompt-level only, not runtime-enforced[/-] [+][FEATURE]: optional runtime enforcement of edit tool's read-before-edit precondition[/+] on May 16, 2026
  3. github-actions commented on May 16, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now follows the contributing guidelines and feature request template. Your description clearly explains the problem (the gap between the documented precondition and actual runtime behavior) and the specific feature ask. Removing the needs:compliance label.

  4. haabe commented on May 19, 2026

    @haabe
    Author

    Happy to draft a PR if it'd help. The additive path that doesn't break existing behaviour: opt-in config flag (e.g. tools.edit.require_prior_read: false by default) that, when set, refuses edits without a prior read in the session. That shape is non-breaking and follows existing config patterns. A maintainer steer on whether that direction is acceptable would save a round-trip. Otherwise no rush — I have a Mycelium-side workaround (plugin guard at tool.execute.before).

  5. github-actions commented on Jul 22, 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