Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

GeminiEditor: replace with expected_replacements and EOL handling (Phase 1a)#155

Closed
enyst wants to merge 8 commits into
OpenHands:mainfrom
enyst:feat/gemini-cli-tools-phase1a
Closed

GeminiEditor: replace with expected_replacements and EOL handling (Phase 1a)#155
enyst wants to merge 8 commits into
OpenHands:mainfrom
enyst:feat/gemini-cli-tools-phase1a

Conversation

@enyst
Copy link
Copy Markdown
Contributor

@enyst enyst commented Aug 16, 2025

Summary

  • Introduce GeminiEditor with Gemini-CLI–compatible replace behavior.

Key Semantics

  • Normalize matching/comparison on LF; preserve original EOLs when writing
  • Error when new_string == old_string
  • If file is missing and old_string == '': create file with new_string
  • If file is missing and old_string != '': error
  • Enforce expected_replacements (default 1); error on mismatch or 0
  • Enforce absolute path and workspace-root boundaries; reject directories
  • Return old/new content to enable accurate upstream diffs

Why

  • Align ACI editor with Gemini-CLI semantics to improve reliability of Gemini models using replace.

Companion PR

  • OpenHands routes FileEditAction(command='replace', impl_source=OH_ACI) to GeminiEditor when present; falls back to OHEditor('str_replace') otherwise.

Co-authored-by: openhands openhands@all-hands.dev

…__init__; add unit tests

Co-authored-by: OpenHands-GPT-5 openhands@all-hands.dev
@enyst enyst changed the title GeminiEditor (Phase 1a): Gemini-CLI–style replace with EOL preservation and expected_replacements GeminiEditor (Phase 1a): Gemini replace with EOL and expected_replacements Aug 16, 2025
@enyst enyst changed the title GeminiEditor (Phase 1a): Gemini replace with EOL and expected_replacements GeminiEditor: replace with EOL and expected_replacements Aug 16, 2025
@enyst enyst changed the title GeminiEditor: replace with EOL and expected_replacements GeminiEditor: replace with expected_replacements and EOL handling (Phase 1a) Aug 16, 2025
openhands-agent and others added 7 commits August 16, 2025 23:06
…CLIResult.error on parameter issues\n\nMatches unit test expectations in tests/unit/editor/test_gemini_editor.py.\n\nCo-authored-by: openhands <openhands@all-hands.dev>
Helps reduce the amount of retries when using an LLM like Devstral.
…fixes OpenHands#154) (OpenHands#157)

* editor: clamp view_range end to file length, emit warning instead of error when beyond EOF (fixes OpenHands#154)

- Normalize end_line by capping to num_lines and allow -1 as before
- Append NOTE: warning to output when clamped
- Update tests to assert on warning text

Co-authored-by: openhands <openhands@all-hands.dev>

* Prepend warning message instead of appending it

Co-authored-by: openhands <openhands@all-hands.dev>

* Update openhands_aci/editor/editor.py

* Update openhands_aci/editor/editor.py

* bump to 0.3.2

* Update tests/integration/editor/test_error_handling.py

---------

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Ryan H. Tran <descience.thh10@gmail.com>
@neubig neubig closed this Dec 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants