Skip to content

fix(workspace): X-Session-API-Key header missing on POST requests to agent-server#3584

Open
Dr1985 wants to merge 1 commit into
OpenHands:mainfrom
Dr1985:issue-3574
Open

fix(workspace): X-Session-API-Key header missing on POST requests to agent-server#3584
Dr1985 wants to merge 1 commit into
OpenHands:mainfrom
Dr1985:issue-3574

Conversation

@Dr1985

@Dr1985 Dr1985 commented Jun 9, 2026

Copy link
Copy Markdown

HUMAN:

This PR will close issue #3574.

  • A human has tested these changes.

AGENT:


Why

RemoteWorkspaceMixin._headers only returns {"X-Session-API-Key": api_key}
when api_key is explicitly passed as a constructor argument. There is no
fallback to the environment variables already used by the agent-server ecosystem
(OH_SESSION_API_KEYS_0 and SESSION_API_KEY).

When a caller (e.g., the Web UI) creates RemoteWorkspace(host=..., working_dir=...)
without providing api_key, every HTTP request from the SDK lacks the auth header.

Summary

-When the OpenHands Web UI creates a RemoteWorkspace without explicitly passing
api_key, the X-Session-API-Key header is never sent in HTTP requests to the
agent-server. This causes 401 Unauthorized errors on all POST endpoints.

-GET requests may incidentally succeed because the agent-server's session API key
validation is only active when OH_SESSION_API_KEYS_* environment variables are
set (i.e., config.session_api_keys is non-empty). When the validator is
active, ALL /api/* routes require the header regardless of HTTP method.

Issue Number

Closes #3574

How to Test

All 122 workspace tests pass:

uv run pytest tests/sdk/workspace/ -v

Video/Screenshots

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

@Dr1985 Dr1985 marked this pull request as ready for review June 9, 2026 07:34
@Dr1985 Dr1985 marked this pull request as draft June 9, 2026 07:38
@Dr1985 Dr1985 marked this pull request as ready for review June 9, 2026 07:38
@VascoSch92

Copy link
Copy Markdown
Member

Hey @Dr1985

thanks for the PR.

However, i'm not sure this is the right place for the fix

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.

[Bug]: Web UI: X-Session-API-Key header missing on POST requests to agent-server (401 on all POST)

2 participants