Skip to content

feat: add OPENCODE_DISABLE_FILETIME_CHECK flag - #6581

Merged
rekram1-node merged 4 commits into
anomalyco:devfrom
luojiyin1987:dev
Jan 21, 2026
Merged

rekram1-node merged 4 commits into
anomalyco:devfrom
luojiyin1987:dev

Conversation

@luojiyin1987

Copy link
Copy Markdown
Contributor

Summary

Adds a new environment variable OPENCODE_DISABLE_FILETIME_CHECK that allows users to skip the FileTime verification check before editing files.

Problem

Currently, OpenCode enforces that files must be read before editing, tracked by timestamps. This causes issues:

  • Time precision errors cause false positives when file wasn't actually modified
  • AI must re-read files that are already in context, wasting tokens
  • Users report 0.2s between read and edit still triggers error

Solution

Added OPENCODE_DISABLE_FILETIME_CHECK flag that:

  • When set to true: Skips all FileTime checks, allowing edits without re-reading
  • When not set or set to false: Maintains existing default behavior for safety

Changes

  • Added OPENCODE_DISABLE_FILETIME_CHECK constant in packages/opencode/src/flag/flag.ts
  • Modified FileTime.assert() in packages/opencode/src/file/time.ts to check flag
  • Added comprehensive tests in packages/opencode/test/file/time-flag.test.ts

Testing

All tests pass:

  • ✅ Flag enabled: FileTime check is skipped
  • ✅ Flag disabled: FileTime check is enforced
  • ✅ Default behavior: Read then assert works correctly

Usage

```bash

Temporary (single command)

OPENCODE_DISABLE_FILETIME_CHECK=true bun dev

Permanent (add to ~/.bashrc or ~/.zshrc)

export OPENCODE_DISABLE_FILETIME_CHECK=true
```

Trade-offs

This is a convenience vs safety trade-off:

  • Benefit: Eliminates token waste and unnecessary re-reads when context is available
  • Risk: Files modified externally won't trigger a warning, potentially missing external changes

Users who are confident in their workflow can enable this flag for better experience.

Closes #4406

…fication

- Users can disable FileTime check via OPENCODE_DISABLE_FILETIME_CHECK env var
- Fixes issue anomalyco#4406 where time precision causes false positives
- Allows AI to edit files without re-reading when context is available
- Tests verify flag works correctly in both enabled and disabled states

Resolves anomalyco#4406
@rekram1-node
rekram1-node merged commit c9ea966 into anomalyco:dev Jan 21, 2026
3 of 4 checks passed
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
MarsQiu007 referenced this pull request in MarsQiu007/openNovel Jul 31, 2026
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why must the read tool be executed before the edit tool

2 participants