Skip to content

Commit

Permalink
fix saves (All-Hands-AI#3848)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren authored Sep 12, 2024
1 parent 58de522 commit 1f13d80
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions openhands/server/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,8 @@ async def select_file(file: str, request: Request):
HTTPException: If there's an error opening the file.
"""
runtime: Runtime = request.state.session.agent_session.runtime
# prepend `/workspace`
file = os.path.join(runtime.config.workspace_mount_path_in_sandbox, file)

file = os.path.join(runtime.config.workspace_mount_path_in_sandbox, file)
read_action = FileReadAction(file)
observation = runtime.run_action(read_action)

Expand Down Expand Up @@ -701,15 +700,11 @@ async def save_file(request: Request):
if not file_path or content is None:
raise HTTPException(status_code=400, detail='Missing filePath or content')

# Make sure file_path is abs
if not os.path.isabs(file_path):
return JSONResponse(
status_code=status.HTTP_400_BAD_REQUEST,
content={'error': 'File path must be absolute'},
)

# Save the file to the agent's runtime file store
runtime: Runtime = request.state.session.agent_session.runtime
file_path = os.path.join(
runtime.config.workspace_mount_path_in_sandbox, file_path
)
write_action = FileWriteAction(file_path, content)
observation = runtime.run_action(write_action)

Expand Down

0 comments on commit 1f13d80

Please sign in to comment.