Skip to content

feat(tools): Include the new content after edits#18

Open
BingqingLyu wants to merge 3 commits into
mainfrom
fork-pr-439-feat-read-after-edit
Open

feat(tools): Include the new content after edits#18
BingqingLyu wants to merge 3 commits into
mainfrom
fork-pr-439-feat-read-after-edit

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 27, 2026

Copy link
Copy Markdown
Owner

TLDR

Add a new readAfterEdit configuration option (default: true) that controls whether file content is automatically read and provided to the LLM after edit operations. This enhances the AI's context awareness by including updated file content in responses, making the AI more aware of the changes it has made.

Dive Deeper

This PR introduces a new configuration setting that addresses the most common frustration: the "Failed to edit, 0 occurrences found for old_string" error. This error typically occurs when the AI attempts consecutive edits or follow-up modifications because it loses context of what it just changed.

Previously, after performing file edits, the AI would only receive a success message but wouldn't see the actual updated content. This meant that in multi-step editing workflows, the AI would often try to edit based on its memory of the original file content rather than the current state, leading to failed edits and frustrated users.

Current workaround: Users have to manually tell the AI to re-read the file before each subsequent edit (e.g., "First read the file, then make this change"), which is tedious, interrupts workflow, and isn't obvious to new users.

Key Changes:

  1. New Configuration Setting: Added readAfterEdit boolean setting to the settings schema with default value true
  2. Enhanced Edit Tool: Modified the edit.ts tool to conditionally include the new content in LLM responses after successful edits
  3. Configurable Behavior: Users can disable this feature by setting "readAfterEdit": false in their settings.json
  4. Testing: Added test coverage for both enabled and disabled states.

Benefits:

  • Fixes the Most Common Error: Reduces "Failed to edit, 0 occurrences found" errors by keeping the AI aware of current file state
  • Eliminates Manual Workarounds: No more need to tell the AI "read the file first" before each edit
  • Enables Consecutive Edits: The AI can now relatively perform multi-step editing workflows without losing track of changes
  • Improved AI Context: The AI can see the results of its edits immediately, leading to better follow-up suggestions
  • Better User Experience: More coherent conversations where the AI acknowledges and builds upon the changes it made
  • Configurable: Users who prefer the previous behavior can disable the feature

Reviewer Test Plan

To validate this change:

  1. Test with feature enabled (default):

    • Create a test file and ask the AI to edit it
    • Ask follow-up questions about the edited content to confirm the AI is aware of changes
    • The AI should demonstrate knowledge of what it just changed (this tests that the file content was included in llmContent)
  2. Test with feature disabled:

    • Set "readAfterEdit": false in your settings.json
    • Perform the same edit operation
    • Ask follow-up questions about the edited content
    • The AI should be less aware of the specific changes made (since file content is not included in llmContent)
  3. Test edge cases:

    • Test file creation (empty old_string)
    • Test multiple replacements
    • Test error scenarios (file not found, multiple matches) - these should behave the same regardless of the setting
    • Test with large files to ensure performance is acceptable
  4. Example prompts to test:

    • "Create a new file called test.js with a simple function"
    • "Replace the function name in test.js from 'hello' to 'greet'" (simplified example, the effect is more apparent with multi-step editing and large files)
    • "Now explain what you just changed" (this should show different behavior based on the setting)
    • "Add error handling to the function you just created" (AI should be more context-aware with feature enabled)

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

ajiwo and others added 3 commits August 25, 2025 13:56
Introduces a new configuration setting, `readAfterEdit`, which is enabled by
default.

When this setting is active, the `edit` tool will automatically append the full
content of a file to its response message (`llmContent`) after a successful
modification or creation.

This provides the AI with immediate context of the changes, improving its
awareness of the file's current state and reducing the need for a subsequent
`read_file` call.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Introduces a new configuration setting, `readAfterEdit`, which is enabled by
default.

When this setting is active, the `edit` tool will automatically append the full
content of a file to its response message (`llmContent`) after a successful
modification or creation.

This provides the AI with immediate context of the changes, improving its
awareness of the file's current state and reducing the need for a subsequent
`read_file` call.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@BingqingLyu

BingqingLyu commented May 7, 2026

Copy link
Copy Markdown
Owner Author

Conflict Group 1

This PR shares modified functions with 17 other PR(s): #10, #106, #112, #113, #114, #117, #14, #17, #21, #22, #31, #36, #46, #7, #75, #86, #88.

These PRs should be reviewed as a batch — merging one may affect the others.

Function File Also modified by
isSdkMcpServerConfig config.ts #106, #112, #113, #114, #117, #46, #75, #86, #88
normalizeConfigOutputFormat config.ts #106, #112, #113, #114, #117, #75, #86, #88
parseArguments config.ts #10, #112, #113, #114, #117, #14, #17, #21, #22, #31, #36, #46, #7, #86, #88
graph LR
    PR18["PR #18"]
    FisSdkMcpServerConfig_803["isSdkMcpServerConfig<br>config.ts"]
    PR18 -->|modifies| FisSdkMcpServerConfig_803
    PR106["PR #106"]
    PR106 -->|modifies| FisSdkMcpServerConfig_803
    PR112["PR #112"]
    PR112 -->|modifies| FisSdkMcpServerConfig_803
    PR113["PR #113"]
    PR113 -->|modifies| FisSdkMcpServerConfig_803
    PR114["PR #114"]
    PR114 -->|modifies| FisSdkMcpServerConfig_803
    PR117["PR #117"]
    PR117 -->|modifies| FisSdkMcpServerConfig_803
    PR46["PR #46"]
    PR46 -->|modifies| FisSdkMcpServerConfig_803
    PR75["PR #75"]
    PR75 -->|modifies| FisSdkMcpServerConfig_803
    PR86["PR #86"]
    PR86 -->|modifies| FisSdkMcpServerConfig_803
    PR88["PR #88"]
    PR88 -->|modifies| FisSdkMcpServerConfig_803
    FnormalizeConfigOutputFormat_803["normalizeConfigOutputFormat<br>config.ts"]
    PR18 -->|modifies| FnormalizeConfigOutputFormat_803
    PR106 -->|modifies| FnormalizeConfigOutputFormat_803
    PR112 -->|modifies| FnormalizeConfigOutputFormat_803
    PR113 -->|modifies| FnormalizeConfigOutputFormat_803
    PR114 -->|modifies| FnormalizeConfigOutputFormat_803
    PR117 -->|modifies| FnormalizeConfigOutputFormat_803
    PR75 -->|modifies| FnormalizeConfigOutputFormat_803
    PR86 -->|modifies| FnormalizeConfigOutputFormat_803
    PR88 -->|modifies| FnormalizeConfigOutputFormat_803
    FparseArguments_6977["parseArguments<br>config.ts"]
    PR18 -->|modifies| FparseArguments_6977
    PR10["PR #10"]
    PR10 -->|modifies| FparseArguments_6977
    PR112 -->|modifies| FparseArguments_6977
    PR113 -->|modifies| FparseArguments_6977
    PR114 -->|modifies| FparseArguments_6977
    PR117 -->|modifies| FparseArguments_6977
    PR14["PR #14"]
    PR14 -->|modifies| FparseArguments_6977
    PR17["PR #17"]
    PR17 -->|modifies| FparseArguments_6977
    PR21["PR #21"]
    PR21 -->|modifies| FparseArguments_6977
    PR22["PR #22"]
    PR22 -->|modifies| FparseArguments_6977
    PR31["PR #31"]
    PR31 -->|modifies| FparseArguments_6977
    PR36["PR #36"]
    PR36 -->|modifies| FparseArguments_6977
    PR46 -->|modifies| FparseArguments_6977
    PR7["PR #7"]
    PR7 -->|modifies| FparseArguments_6977
    PR86 -->|modifies| FparseArguments_6977
    PR88 -->|modifies| FparseArguments_6977
Loading

Posted by codegraph-ai conflict detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants