Skip to content

fix(api): handle read_image file errors - #74

Merged
Sonorous281 merged 1 commit into
RLinf:mainfrom
wkzCode:fix/api-read-image-errors
Aug 7, 2026
Merged

fix(api): handle read_image file errors#74
Sonorous281 merged 1 commit into
RLinf:mainfrom
wkzCode:fix/api-read-image-errors

Conversation

@wkzCode

@wkzCode wkzCode commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve relative image paths from the repository root, matching read_text_file
  • return structured tool errors for missing files, directories, and image read failures instead of aborting the API agent run
  • preserve ToolReturn with binary image content for successful reads
  • add coverage for missing, directory, read-failure, and successful relative-path cases

Motivation

API planner models can occasionally mistype a long image path. BinaryContent.from_path() currently lets FileNotFoundError escape, which terminates the entire agent after earlier physical actions may already have executed. Returning the error to the model makes this behavior consistent with read_text_file and allows the model to recover safely.

Validation

  • git diff --check
  • python -m compileall -q rpent/planner/api_loop.py tests/test_api_read_image.py
  • pytest was not run locally because the available Python environments do not have pydantic_ai/pytest installed

@jx-qiu jx-qiu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Some minor comments:

Comment thread rpent/planner/api_loop.py
Comment thread rpent/planner/api_loop.py
@Sonorous281
Sonorous281 merged commit 97ad4ff into RLinf:main Aug 7, 2026
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.

3 participants