Skip to content

Conversation

@kaizen403
Copy link
Contributor

@kaizen403 kaizen403 commented Feb 4, 2026

Fixes #1363 - When Prometheus creates complex plans that exceed output limits and writes in segments, the Write tool overwrites previous content instead of appending.

Problem?

When creating large plans, Prometheus may need to write content in multiple segments. However:

  1. The Write tool overwrites files by design (does NOT append)
  2. The prompt instructs Prometheus to use Edit for subsequent sections, but this isn't enforced
  3. Result: Only the last segment is preserved, causing significant content loss

Solution:

Added plan file overwrite protection to the prometheus-md-only hook:

  1. Track written plan files per session using a Map of session ID → Set of normalized file paths
  2. Block subsequent Write calls to the same plan file with a clear error message
  3. Instruct agent to use Edit tool to append content instead
  4. Session cleanup on session.deleted and session.compacted events

Changes

  1. src/hooks/prometheus-md-only/index.ts:

    • Added writtenPlanFiles Map to track plan files written per session
    • Added isPlanFile() and normalizeFilePath() helper functions
    • Block second Write to same plan file with instructional error message
    • Added event handler for session cleanup
  2. src/hooks/prometheus-md-only/index.test.ts:

    • Added 6 new tests for overwrite protection:
      • First write allowed
      • Second write blocked with "use Edit" message
      • Different plan files allowed
      • Edit after Write allowed
      • Per-session tracking (different sessions independent)
      • Draft files NOT protected (multiple writes allowed)

Scope

File Type Protected? Reason
.sisyphus/plans/*.md ✅ YES Plans are final output, loss is critical
.sisyphus/drafts/*.md ❌ NO Drafts are working memory, can be fully replaced

Error Message Example

[prometheus-md-only] Plan file ".sisyphus/plans/my-plan.md" has already been written in this session.
The Write tool OVERWRITES content. To add more sections, use Edit tool to append.
Example: Edit(filePath=".sisyphus/plans/my-plan.md", oldString="## Success Criteria", newString="## More TODOs\n...\n## Success Criteria")

Testing

  • All 32 prometheus-md-only tests pass (including 6 new tests)
  • Typecheck passes
  • Build successful

Checklist

  • Fix implemented
  • Tests added (TDD approach)
  • All tests pass
  • Typecheck passes
  • PR targets dev branch

Summary by cubic

Prevents plan content loss by blocking repeated Write calls to the same plan file and guiding the agent to use Edit to append. Applies per session to .sisyphus/plans/*.md; drafts are not affected.

  • Bug Fixes
    • Track written plan files per session with normalized paths.
    • Block a second Write to the same plan file with a clear “use Edit” message.
    • Allow Edit after Write and writes to different plan files; drafts remain overwritable.
    • Clean up tracking on session.deleted/compacted; added tests covering these cases.

Written for commit 7b2a5d5. Summary will update on new commits.

…plan file

Fixes code-yeongyu#1363 - When Prometheus creates complex plans in segments, the Write
tool overwrites previous content instead of appending. This fix:

- Tracks plan files that have been written to per session
- Blocks subsequent Write calls to the same plan file
- Provides clear error message instructing to use Edit tool to append
- Cleans up state on session.deleted and session.compacted events

Draft files (.sisyphus/drafts/) are NOT affected - multiple writes allowed
since drafts are working memory that can be fully replaced.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@kaizen403
Copy link
Contributor Author

@sisyphus-dev-ai review

@kaizen403
Copy link
Contributor Author

hello @code-yeongyu. this fixes #1363 and prevents plan content loss by blocking subsequent Write calls and guiding to use Edit instead. all tests pass.

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.

[Bug]: When using Prometheus to create a complex plan, the content at the beginning of the plan file is overwritten by the content at the end

1 participant