Skip to content

feat(server): support accessing sandbox endpoints via server proxy#172

Merged
Pangjiping merged 5 commits intoalibaba:mainfrom
fengxsong:server_proxy
Feb 6, 2026
Merged

feat(server): support accessing sandbox endpoints via server proxy#172
Pangjiping merged 5 commits intoalibaba:mainfrom
fengxsong:server_proxy

Conversation

@fengxsong
Copy link
Contributor

Summary

what's changed.

  • Add server-side proxy routes to allow clients to access internal sandbox endpoints via server transit
  • Add use_server_proxy option in SDK connection configuration; automatically rewrite endpoint URLs when enabled
  • Add httpx[socks] dependency to support proxy functionality, and configure uv index source

why

When the server is deployed in Kubernetes and exposed via a gateway, while local clients cannot connect directly to the sandboxes created by the controller, we can have the server forward proxy requests to the execd process of the sandbox pods.

Testing

  • Not run (explain why)
  • Unit tests
  • Integration tests
  • e2e / manual verification

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

@Pangjiping
Copy link
Collaborator

Great addition! However, I'm not clear on one thing: are you using Kubernetes resource objects to create sandbox, or are you using Docker service with DinD (Docker in Docker)?

Your current implementation might not be compatible with the WebSocket protocol. Regarding Kubernetes ingress-gateway, you might want to check out #164 as well.

@fengxsong
Copy link
Contributor Author

@Pangjiping We plan to build an in-house AI infra platform based on the OpenSandbox project, with all sandboxes running on Virtual Kubelet deployed on ACK. For R&D who don’t have Kind or Docker installed locally, it can be a bit cumbersome to develop AI agents that are integrated with sandboxes. I’ve researched the kubernetes-sigs/agent-sandbox repo before, which adopts a similar implementation approach, kind of. There are several components in this repository that I haven’t had time to go through yet...

@Pangjiping
Copy link
Collaborator

Pangjiping commented Feb 4, 2026

LGTM. It provides a direct solution for systems that cannot leverage ingress-gateway for service discovery. However, there are a couple of things to consider:

  1. Does the server support proxying the WebSocket protocol? If not, please add a TODO in the code.
  2. Could you include some working code examples or test results in the PR comments?

Additionally, please ask @ninan-nn to review the python SDK changes.

@Pangjiping Pangjiping added the feature New feature or request label Feb 4, 2026
@fengxsong
Copy link
Contributor Author

how to test

  1. run server component in a kubernetes cluster, then expose it with a ingress resource
  2. run the demo code, https://github.com/alibaba/OpenSandbox/tree/main/examples/agent-sandbox

because the client can not reach the private IP address of the sandbox pod, then the demo code will fail with error message like timeout....

  1. modify the ConnectionConfig construct function
    ....
    config = ConnectionConfig(
        domain=domain,
        api_key=api_key,
        request_timeout=timedelta(seconds=60),
        use_server_proxy=True,
    )

Copy link
Collaborator

@hittyt hittyt left a comment

Choose a reason for hiding this comment

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

This PR includes unrelated formatting changes mixed with functional changes. Could you revert the formatting-only changes to keep the diff focused? This makes review easier and keeps git history clean.

Check if your IDE is auto-formatting on save - you may want to disable it or align with the project's style config.

@fengxsong
Copy link
Contributor Author

@hittyt has been done. PTAL

Copy link
Collaborator

@Pangjiping Pangjiping left a comment

Choose a reason for hiding this comment

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

please rebase main

@Pangjiping
Copy link
Collaborator

LGTM. Please @ninan-nn review sdk changes.

Pangjiping
Pangjiping previously approved these changes Feb 6, 2026
Copy link
Collaborator

@ninan-nn ninan-nn left a comment

Choose a reason for hiding this comment

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

Plz add sync implementation as well for python sdk : >

@fengxsong
Copy link
Contributor Author

@ninan-nn do you mean the JS/Kotlin SDKs? I'm not quite familiar with these two programming languages. Maybe we can add a todo list?

@Pangjiping
Copy link
Collaborator

This will be released with server/v0.1.1

@ninan-nn
Copy link
Collaborator

ninan-nn commented Feb 6, 2026

@ninan-nn do you mean the JS/Kotlin SDKs? I'm not quite familiar with these two programming languages. Maybe we can add a todo list?

@fengxsong Sorry for the confusion. I was referring to the Python sync client, not other language SDKs.

Please check the sync implementation under
OpenSandbox/sdks/sandbox/python/src/opensandbox/sync/
and make sure this feature is also applied there. 👀

Copy link
Collaborator

@ninan-nn ninan-nn left a comment

Choose a reason for hiding this comment

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

LGTM

@ninan-nn
Copy link
Collaborator

ninan-nn commented Feb 6, 2026

This feature will be available in the next SDK release.

Copy link
Collaborator

@Pangjiping Pangjiping left a comment

Choose a reason for hiding this comment

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

LGTM

@Pangjiping Pangjiping merged commit 09380c6 into alibaba:main Feb 6, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants