Skip to content

Conversation

@Ghazi-raad
Copy link
Contributor

Description

Improves the write_file tool description to explicitly clarify what the content parameter 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

  • Explicitly states that content contains the complete file contents
  • Adds clarifying language: "(this is the actual text/code/data that will be written to the file)"
  • Provides concrete examples showing proper usage
  • Clarifies overwrite behavior
  • Fixes typo: "create the a new file" → "create a new file"

Impact

  • Reduces failed tool call attempts
  • Improves user experience and reduces API costs
  • Fully backward compatible (documentation-only change)
  • Particularly helps with large file creation (>60k tokens)

Testing

  • Existing tests pass
  • Backward compatible (documentation-only change)
  • No breaking changes
  • No functional code changes

Fixes #416

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
Copilot AI review requested due to automatic review settings November 26, 2025 20:50
Copilot finished reviewing on behalf of Ghazi-raad November 26, 2025 20:51
Copy link

Copilot AI left a 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 content contains 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.

- 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
Copy link
Collaborator

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)

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.

write_file tool => no clear description on content

2 participants