Skip to content

[Bug]: File upload responds only {"success": true}, so the SDK and TypeScript remote workspaces report no file_size #5836

Closed

Description

@enyst

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

  1. In a checkout of main: uv sync, then SESSION_API_KEY=dev-key uv run python -m openhands.agent_server --host 127.0.0.1 --port 8000.
  2. head -c 70000 /dev/urandom > /tmp/blob.bin
  3. curl -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).
  4. 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)  # None

With 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 as file_size.
  • The TypeScript RemoteWorkspace.fileUpload reports the same file_size, so write_file no longer says undefined bytes.
  • Existing clients that only read success keep working (the response stays a superset of {"success": true}).
  • A unit test covers the reported size.
  • The map bullet F14.upload-size passes with its # bug marker 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 returns Success() (line 109); Success (openhands-agent-server/openhands/agent_server/models.py:443) has only success.
  • _file_upload_generator (openhands-sdk/openhands/sdk/workspace/remote/remote_workspace_mixin.py:336) sets file_size=result_data.get("file_size").
  • RemoteWorkspace.fileUpload (clients/typescript/src/workspace/remote-workspace.ts:171-177) copies resultData.file_size; clients/typescript/src/conversation/local-conversation.ts:655 prints 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

  1. added
    bug
    ready-for-dev
    on Oct 14, 2026
  2. enyst commented on Oct 14, 2026

    @enyst
    MemberAuthor

    I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.

    Decision needed (maintainer): where the size comes from.

    • Implemented: the server sends it. _upload_file counts the bytes it writes and answers {"success": true, "file_size": N} through a new FileUploadResult(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 only success are unaffected; the SDK (sync and async RemoteWorkspace.file_upload) and the TypeScript RemoteWorkspace.fileUpload already read file_size and need no change, and the SDK's own unit tests were written against this response shape.
    • Alternative: leave the server at {"success": true} and have each client compute the size from what it sent (the SDK from the source file/bytes, TypeScript from the Blob's size). 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_size on the next regeneration; no hand edit.


    Generated by Claude Code

  3. removed
    ready-for-dev
    on Oct 14, 2026
  4. all-hands-bot commented on Oct 14, 2026

    @all-hands-bot
    Collaborator

    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_size comes from. Both options below are viable and the F14.upload-size map bullet passes either way, so this is a product/contract choice that cannot be inferred safely from the code.

    1. Server sends it — _upload_file counts 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 only success are unaffected; the SDK (sync and async) and the TypeScript RemoteWorkspace.fileUpload already read file_size and need no change; the SDK's own unit tests were written against this response shape.
    2. Each client computes it — leave the server response at {"success": true} and have each consumer derive the size from what it sent (the SDK from the source file/bytes, TypeScript from the Blob's size). 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-dev restored.

  5. enyst commented on Oct 14, 2026

    @enyst
    MemberAuthor

    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/upload and the conversation-scoped one) return {"success": true, "file_size": N}, where N is the number of bytes the server actually wrote. That is what #5856 implements. The change is additive, so clients that read only success keep working, and the SDK and TypeScript remote workspaces already read file_size. Restoring ready-for-dev.


    Generated by Claude Code

  6. added
    ready-for-dev
    on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions