Skip to content

Fix RelaceEditTool to handle file not found errors gracefully#824

Draft
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
gen/d561714d-a304-4576-ba72-1c7a6b195fdf
Draft

Fix RelaceEditTool to handle file not found errors gracefully#824
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
gen/d561714d-a304-4576-ba72-1c7a6b195fdf

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 12, 2025

Description

This PR fixes the error handling in the RelaceEditTool to properly handle file not found errors. Previously, when a file was not found, the tool would raise a FileNotFoundError exception, which would be propagated to the user as an error. This PR changes the behavior to return a RelaceEditObservation with an error status instead, which is consistent with how other errors are handled in the tool.

Changes

  • Modified the relace_edit function in src/codegen/extensions/tools/relace_edit.py to return a RelaceEditObservation with an error status when a file is not found, instead of raising a FileNotFoundError.

Testing

This change ensures that when an invalid filepath is provided to the RelaceEditTool, the error is properly passed back to the assistant as part of the observation, rather than causing an exception.

Fixes the error:

FileNotFoundError('File not found: codegen_agi.py')

Now the error will be returned as part of the tool's observation, allowing the assistant to handle it gracefully.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


codegen-bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

1 participant