-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: improve write_file tool description for better LLM clarity #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: improve write_file tool description for better LLM clarity #499
Conversation
Addresses issue langchain-ai#416 by making the content parameter description more explicit and adding usage examples. Changes: - Explicitly states content contains complete file contents - Adds clarifying language about what content represents - Provides concrete examples for Python and text files - Clarifies file overwrite behavior - Fixes typo: 'create the a new file' -> 'create a new file' This change helps LLMs (especially Claude models) understand the content parameter on the first attempt rather than failing 3-10 times before getting it right. Fixes langchain-ai#416
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves the write_file tool description to reduce LLM confusion about the content parameter, addressing community-reported issues where Claude models fail multiple times before correctly providing file content, especially with large files (>60k tokens).
Key changes:
- Explicitly clarifies that
contentcontains complete file contents with explanatory text - Adds concrete usage examples for Python and text files
- Fixes typo and improves formatting consistency
- Clarifies overwrite behavior
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| - Prefer to edit existing files over creating new ones when possible.""" | ||
| - The content parameter contains the complete file contents as a string (this is the actual text/code/data that will be written to the file) | ||
| - The write_file tool will create a new file at the specified path | ||
| - If a file already exists at the path, it will be overwritten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at the moment it's not overwritten. it errors (i.e., overwrites are not allowed)
|
I have tried this solution in 'claude-sonnet-4-5-20250929', But it does't work. |
Description
Improves the
write_filetool description to explicitly clarify what thecontentparameter represents.Problem
The current description is ambiguous, leading to LLMs (especially Claude models) failing 3-10 times before correctly providing the content parameter. Multiple community members have reported this issue, particularly with larger content sizes (>60k tokens).
Related community reports:
Solution
contentcontains the complete file contentsImpact
Testing
Fixes #416