Repository navigation
feat(containers): add Containers API with Docker/OpenShell providers and shell tool - #5853
zanetworker wants to merge 7 commits into
Conversation
Add model definitions for the Containers API: Container, CreateContainerRequest, ListContainersRequest/Response, RetrieveContainerRequest, DeleteContainerRequest/Response, network policies (disabled/allowlist), and expiration settings. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Adel Zaalouk <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Adel Zaalouk <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Adel Zaalouk <[email protected]>
Implements the Containers protocol using Docker SDK with metadata persistence via AuthorizedSqlStore. Includes unit tests with mocked Docker client and container logging category registration. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Adel Zaalouk <[email protected]>
Add shell tool input/output types to the Responses API models matching OpenAI's schema (shell_call, shell_call_output, environment configs). Add exec_in_container to the Containers protocol and Docker provider for running commands in sandboxed containers. Fix containers registry to use standard available_providers() pattern. Include unit tests for all new types and conformance tests validated against OpenAI's live API. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Adel Zaalouk <[email protected]>
Add containers API as an optional dependency of the Responses provider. Thread containers_api through the provider chain to the ToolExecutor, which dispatches shell tool calls by executing commands in containers via exec_in_container. Register shell as a server-side builtin tool so the streaming orchestrator presents it to models as a callable function. Auto-delete containers created by container_auto after execution. Register Containers protocol in the resolver and add containers to the starter distribution. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Adel Zaalouk <[email protected]>
✱ Stainless preview buildsThis PR will update the Edit this comment to update it. It will appear in the SDK's changelogs. ✅ llama-stack-client-openapi studio · code · diff
✅ llama-stack-client-node studio · code · diff
✅ llama-stack-client-python studio · code · diff
✅ llama-stack-client-go studio · conflict
This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push. |
Add an OpenShell provider to the Containers API that manages sandboxed environments via OpenShell's gRPC gateway instead of Docker. This gives production deployments a security-hardened execution backend with per-binary network policies, credential isolation, and L7 inspection. The provider uses the openshell Python SDK (SandboxClient) with three connection modes: explicit gateway endpoint, cluster name auto-discovery, or active cluster fallback. Network policy mapping is deferred to a follow-up; sandboxes use OpenShell's default policy. Uses a separate SQLite table (openshell_containers) to avoid collisions with the Docker provider's table schema. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Adel Zaalouk <[email protected]>
|
This pull request has merge conflicts that must be resolved before it can be merged. @zanetworker please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork |
|
This pull request has been automatically marked as stale because it has not had activity within 60 days. It will be automatically closed if no further activity occurs within 30 days. |
What does this PR do?
Adds a Containers API for managing sandboxed Docker execution environments, matching the OpenAI Containers API. This enables models to execute shell commands in isolated containers via the Responses API shell tool.
Only the Docker provider is implemented in this PR. Other providers (Podman, Kubernetes, Openshell, remote container services) can follow in separate PRs.
Closes #5852
API Surface
/v1/containers/v1/containers/v1/containers/{id}/v1/containers/{id}/v1/containers/{id}/execShell Tool Integration
The Responses API now accepts
{"type": "shell", "environment": {"type": "container_auto"}}as a tool. When a model emits ashell_call, the server:python:3.12-slim)docker execThe
containersAPI is registered as an optional dependency of the Responses provider, so servers without Docker continue to work normally.Implementation
src/ogx_api/containers/— Pydantic models matching OpenAI's schema (Container, ExpiresAfter, NetworkPolicy, ExecInContainer)src/ogx/providers/inline/containers/docker/— manages lifecycle via Docker SDK, metadata persisted to AuthorizedSqlStoresrc/ogx_api/openai_responses.py— ShellContainerAutoEnvironment, ShellContainerReferenceEnvironment, ShellCallAction, ShellOutputContent, ShellExitOutcome, ShellTimeoutOutcome, OpenAIResponseOutputMessageShellCall, OpenAIResponseOutputMessageShellCallOutputshellcalls to the Containers API;_coordinate_tool_executionandconvert_toolhandle the new type; auto-cleanup viafinallyblockWhat is NOT in this PR
environment.skills) — follow-upTest Plan
Unit tests (38 tests)
uv run pytest tests/unit/containers/ tests/unit/providers/containers/ -v # 38 passedOpenAI conformance (6 tests, requires OPENAI_API_KEY)
OPENAI_API_KEY=sk-... uv run pytest tests/integration/containers/test_openai_conformance.py -v # 6 passed — validates response shapes match OpenAI's live APIEnd-to-end server test
Output:
Full unit suite regression check
uv run pytest tests/unit/ --ignore=tests/unit/providers/vector_io -x --tb=short -q # 2359 passed, 3 skipped, 3 xfailed