Repository navigation
Description
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
Is there an existing issue for the same bug?
- I have searched existing issues and this is not a duplicate.
Bug Description
POST /api/file/upload (and the conversation-scoped POST /api/conversations/{runtime_conversation_id}/file/upload) answers only {"success": true}. Both remote workspace clients read a file_size from that response and copy it into their upload result, so it is always missing: the SDK's RemoteWorkspace.file_upload / AsyncRemoteWorkspace.file_upload return file_size=None, and the TypeScript RemoteWorkspace.fileUpload returns file_size: undefined. The TypeScript LocalConversation write_file tool then tells the model Successfully wrote undefined bytes to <path>. LocalWorkspace.file_upload, whose contract the remote workspaces mirror, reports the destination's size.
Expected Behavior
Uploading a 70000-byte file through RemoteWorkspace.file_upload (SDK) or RemoteWorkspace.fileUpload (TypeScript) reports file_size == 70000, the same as LocalWorkspace.file_upload, and the TypeScript write_file tool reports Successfully wrote 70000 bytes.
Actual Behavior
Every upload lands byte for byte, but the response body is {"success": true}; the SDK reports file_size=None and the TypeScript client file_size: undefined.
Steps to Reproduce
- In a checkout of main:
uv sync, thenSESSION_API_KEY=dev-key uv run python -m openhands.agent_server --host 127.0.0.1 --port 8000. head -c 70000 /dev/urandom > /tmp/blob.bincurl -s -H 'X-Session-API-Key: dev-key' -F file=@/tmp/blob.bin 'http://127.0.0.1:8000/api/file/upload?path=/tmp/up/blob.bin'prints{"success":true}(no size).- SDK:
from openhands.sdk.workspace.remote.base import RemoteWorkspace
ws = RemoteWorkspace(host="http://127.0.0.1:8000", api_key="dev-key", working_dir="/tmp")
print(ws.file_upload("/tmp/blob.bin", "/tmp/up/sdk.bin").file_size) # NoneWith the verify-agent-server skill: control-agent-server map run --file F14 --only F14.upload-size --fresh reports the known-bug bullet as an expected failure while the bug lasts.
Acceptance Criteria
- A successful upload (global and conversation-scoped route) reports the number of bytes written, and
RemoteWorkspace.file_upload(sync and async) reports it asfile_size. - The TypeScript
RemoteWorkspace.fileUploadreports the samefile_size, sowrite_fileno longer saysundefined bytes. - Existing clients that only read
successkeep working (the response stays a superset of{"success": true}). - A unit test covers the reported size.
- The map bullet
F14.upload-sizepasses with its# bugmarker removed.
Installation Method
uv sync in a checkout of main
Version
main at 6e7a853
Additional Context
Root cause:
_upload_file(openhands-agent-server/openhands/agent_server/file_router.py:85) streams the body to disk and returnsSuccess()(line 109);Success(openhands-agent-server/openhands/agent_server/models.py:443) has onlysuccess._file_upload_generator(openhands-sdk/openhands/sdk/workspace/remote/remote_workspace_mixin.py:336) setsfile_size=result_data.get("file_size").RemoteWorkspace.fileUpload(clients/typescript/src/workspace/remote-workspace.ts:171-177) copiesresultData.file_size;clients/typescript/src/conversation/local-conversation.ts:655prints it.
The SDK's own unit tests already mock the response as {"success": true, "file_size": 12} (tests/sdk/workspace/remote/test_remote_workspace_mixin.py:343), i.e. the clients were written against a response that includes the size. Two fixes are possible: the server sends file_size (one change, every client benefits), or each client computes the size locally. Upload atomicity and the 500 for uploads onto a directory are separate items in the same umbrella.
Found by the first full agentic run of verify-agent-server; tracked in #5653.
Activity
enyst commentedon Oct 14, 2026
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
Decision needed (maintainer): where the size comes from.
_upload_filecounts the bytes it writes and answers{"success": true, "file_size": N}through a newFileUploadResult(Success)response model, on both the global and the conversation-scoped upload route (they share the handler). This is additive to the REST contract, so clients that read onlysuccessare unaffected; the SDK (sync and asyncRemoteWorkspace.file_upload) and the TypeScriptRemoteWorkspace.fileUploadalready readfile_sizeand need no change, and the SDK's own unit tests were written against this response shape.{"success": true}and have each client compute the size from what it sent (the SDK from the source file/bytes, TypeScript from theBlob'ssize). That avoids an OpenAPI change but reports what the client sent rather than what the server wrote, and has to be repeated in every consumer.The F14.upload-size map bullet passes either way. The TypeScript generated schema is pinned to the released contract, so it picks up
file_sizeon the next regeneration; no hand edit.Generated by Claude Code
all-hands-bot commentedon Oct 14, 2026
The following comments were added by the OpenHands AI agent.
Decision needed
The bug reproduces and is root-caused, but it is not ready for development until the maintainer decision raised in the discussion is resolved: where the uploaded
file_sizecomes from. Both options below are viable and theF14.upload-sizemap bullet passes either way, so this is a product/contract choice that cannot be inferred safely from the code._upload_filecounts the bytes it writes and returns{"success": true, "file_size": N}on both the global and conversation-scoped upload route. Additive to the REST contract, so clients that read onlysuccessare unaffected; the SDK (sync and async) and the TypeScriptRemoteWorkspace.fileUploadalready readfile_sizeand need no change; the SDK's own unit tests were written against this response shape.{"success": true}and have each consumer derive the size from what it sent (the SDK from the source file/bytes, TypeScript from theBlob'ssize). Avoids an OpenAPI change but reports what the client sent rather than what the server wrote, and must be repeated in every consumer.Focused question: which option should this issue be scoped to? Once answered, the acceptance criteria can be finalized (server-side byte count on both routes, or client-side size in the SDK and TypeScript clients) and
ready-for-devrestored.enyst commentedon Oct 14, 2026
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
Decision: Engel chose server-reported size. The upload routes (
POST /api/file/uploadand the conversation-scoped one) return{"success": true, "file_size": N}, whereNis the number of bytes the server actually wrote. That is what #5856 implements. The change is additive, so clients that read onlysuccesskeep working, and the SDK and TypeScript remote workspaces already readfile_size. Restoringready-for-dev.Generated by Claude Code