Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1542·SWE-agent

[Bug]: windowed edit tool parses replace_all with type=bool, so "false"/"0" enable replace-all

Author: Shxiao101Created Sep 6, 2026Updated Sep 6, 2026

Describe the bug

The edit tool in the windowed_edit_replace bundle parses its optional third argument with argparse type=bool:

python
# tools/windowed_edit_replace/bin/edit, get_parser()
parser.add_argument("replace_all", type=bool, nargs="?", default=False)

bool("false"), bool("False") and bool("0") are all True, so any non-empty string enables replace-all. This makes it impossible for the model to request a single (first-occurrence-only) replacement by passing an explicit false-y value, which contradicts the tool docstring ("If replace-all is True, replace all occurrences...").

This affects both invocation paths:

  1. Function calling: replace-all is declared as type: boolean in config.yaml. A JSON false reaches get_quoted_arg() in sweagent/tools/parsing.py, is returned as-is (non-str), rendered through the {{value}} template into the literal string False, and the command line becomes edit <search> <replace> False — which the parser turns into True.
  2. Backtick/template path: the model writes edit <search> <replace> false directly, same result.

Steps/commands/code to Reproduce

python
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("search", type=str)
parser.add_argument("replace", type=str)
parser.add_argument("replace_all", type=bool, nargs="?", default=False)

for argv in (["a", "b", "false"], ["a", "b", "False"], ["a", "b", "0"], ["a", "b"]):
    print(argv, "->", parser.parse_args(argv).replace_all)

End-to-end (function-calling path, verified against main @ 3ea751c using the real Command model and the parsing.py rendering logic):

JSON {"replace-all": false}
  -> command line: 'edit hello world False'
  -> parser sees replace_all = True   # wrong

Error message/results

argv (third argument) current replace_all expected
"false" True False
"False" (function-calling rendering of JSON false) True False
"0" True False
"true" True True
omitted False False

System Information

Windows 11 x64, Python 3.13.9, verified against main @ 3ea751c. The bug is version-independent (argparse type=bool behavior).

Source: SWE-agent/SWE-agent

View original on GitHubView discussion on GitHub