Skip to content

feat: add append mode to file_write tool#493

Open
xlyoung wants to merge 1 commit into
strands-agents:mainfrom
xlyoung:fix/file-write-append-mode
Open

feat: add append mode to file_write tool#493
xlyoung wants to merge 1 commit into
strands-agents:mainfrom
xlyoung:fix/file-write-append-mode

Conversation

@xlyoung
Copy link
Copy Markdown

@xlyoung xlyoung commented Jun 4, 2026

Problem

The file_write tool hardcodes open(path, 'w'), always overwriting the file. The documentation at strandsagents.com claims append mode is supported, but the implementation doesn't support it.

Fix

Add optional mode parameter to file_write:

  • mode='w' (default): overwrite file — existing behavior preserved
  • mode='a': append content to existing file

Changes

  1. TOOL_SPEC: Add mode parameter with enum ['w', 'a'] and default 'w'
  2. Function: Read mode from tool input, use it in open(path, mode)
  3. Success message: Reflect whether content was 'written to' or 'appended to'

Testing

All 9 file_write tests pass with no changes needed.

Fixes #344

Add optional 'mode' parameter to file_write tool that allows appending
content to existing files instead of always overwriting.

- mode='w' (default): overwrite file (existing behavior)
- mode='a': append content to existing file

The documentation at strandsagents.com claims append mode is supported,
but the implementation hardcoded open(path, 'w'). This fix aligns the
implementation with the documented behavior.

Fixes strands-agents#344
@xlyoung xlyoung requested a deployment to manual-approval June 4, 2026 06:55 — with GitHub Actions Waiting
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.

file_write tool missing append support despite documentation claims

1 participant