---
url: /v7.0/en-us/data-agent-deployment.md
---
# Data Agent deployment and system requirements

This page applies to Data Agent in HENGSHI SENSE 7.0. Install the HENGSHI service and its existing dependencies with the selected method, then prepare OpenSandbox as described here. Data Agent is an optional licensed capability; when enabled, OpenSandbox provides an isolated Agent runtime.

## Deployment structure and methods

OpenSandbox is a separate sandbox lifecycle service. It assigns or creates temporary containers with the Data Agent runtime, HBI, and built-in skills, then reclaims them according to the runtime policy. It can run on the same suitable host as HENGSHI, on a dedicated Linux host, or in a Kubernetes cluster. Kernel and network requirements apply to the host or worker that actually creates sandboxes; the HENGSHI service VM does not need to host them.

```text
Browser / SDK → HENGSHI service → OpenSandbox lifecycle service → Agent sandbox
                       ↑                                           ↓
                       └──────── Authenticated HENGSHI API ← HBI ────┘
                                            Sandbox → Responses model service
```

The runtime environment provides Linux OCI containers, container networking, credential proxying, and the required platform permissions. Prepare these components from the versioned delivery manifest.

| HENGSHI deployment | OpenSandbox placement and installation | Connection |
| --- | --- | --- |
| [Linux standalone package](install-first.md) / [Ansible cluster](install-first-cluster.md) | Keep the HENGSHI service on its existing installation path; run OpenSandbox on the same host if it meets system requirements, or on a dedicated Linux Docker host. Ansible distributes HENGSHI connection settings only | All HENGSHI nodes connect to the same OpenSandbox service; move the runtime to a separate host if the service VM does not meet sandbox-host requirements |
| [Docker Compose](docker.md) | The existing HENGSHI Compose project does not start OpenSandbox. Start the OpenSandbox Compose project from the 7.0 runtime package separately | Same-host containers connect through the supplied network overlay; cross-host deployments use a private address reachable from HENGSHI |
| [Kubernetes / Helm](k8s.md) / [Helm](helm-install.md) | The platform administrator installs the matching CRDs / controller once per cluster; deploy the Data Agent runtime in a dedicated namespace, then configure the HENGSHI Chart | Cluster-level OpenSandbox components, Data Agent runtime Chart, HENGSHI Chart values, Secrets, and persistent volume |

### Sandbox components and image sources

The “sandbox image” is not a single image. A Data Agent job uses the HENGSHI service, the OpenSandbox lifecycle service, the Data Agent runtime container, and its network-execution components. Use versions and image digests from the same HENGSHI 7.0 delivery manifest.

| Component | Purpose | Source and placement |
| --- | --- | --- |
| HENGSHI Data Agent runtime image | Runs the HBI CLI and built-in skills in a temporary container for each Data Agent job | HENGSHI supplies a separate runtime image reference with the matching 7.0 delivery; the Docker host or Kubernetes worker that runs sandboxes pulls it. It must match the HENGSHI service version |
| OpenSandbox Server | Provides the lifecycle API and calls the container platform to create, manage, and reclaim sandboxes | Use the `opensandbox/server` image and digest pinned in the 7.0 runtime package; run it on the Docker host or as a separate Kubernetes service |
| OpenSandbox execd | Provides command execution and data channels for a sandbox | Use the `opensandbox/execd` image and digest pinned in the runtime package; the OpenSandbox configuration references it |
| OpenSandbox egress | Provides policy-controlled sandbox egress and credential-proxy traffic | Use the `opensandbox/egress` image and digest pinned in the runtime package; the current `dns+nft` configuration requires nftables / netfilter and the required network permissions on sandbox hosts or workers |
| OpenSandbox state store | Stores lifecycle-service state, not HENGSHI conversation history | Docker Compose uses a persistent data volume; Kubernetes uses a persistent volume claim. Keep it across service upgrades |
| OpenSandbox CRDs / controller | Defines and schedules sandbox resources in Kubernetes | Required only for Kubernetes; install the version pinned in the 7.0 runtime package once per cluster and have the platform administrator manage it |

The HENGSHI 7.0 delivery manifest lists the Data Agent runtime image address and `@sha256` digest. This image is separate from the HENGSHI service image and is pulled by the Docker host or Kubernetes worker that runs sandboxes. OpenSandbox images use the upstream repositories `docker.io/opensandbox/server`, `docker.io/opensandbox/execd`, and `docker.io/opensandbox/egress`; the current 7.0 set pins Server 1.1.1, execd 1.1.0, and egress 1.1.7. The runtime package also pins Kubernetes base / controller and CRD versions. In restricted networks, mirror the pinned images to the customer registry without changing their versions or digests. Do not switch to `latest`, `main`, or another moving version.

The 7.0 Data Agent runtime package provides two runbooks: `data-agent/docker-compose/` for Docker hosts and `data-agent/kubernetes/` for Kubernetes clusters. Use their image references, digests, environment examples, and installation steps for site deployment. The HENGSHI service image and Data Agent runtime image must come from the same delivery batch.

### Deployment sequence

1. **Choose where sandboxes will run.** Check the Linux kernel, container networking, nftables / netfilter, egress permissions, and image-pull access on the actual sandbox host or worker—not only on the HENGSHI service VM. The current 7.0 configuration uses `dns+nft`; a tested Linux 3.10 environment cannot start this egress component. If the HENGSHI VM does not meet the requirements, keep HENGSHI there and run OpenSandbox and sandbox containers on a suitable separate Linux host.
2. **Prepare matching delivery artifacts.** Get the HENGSHI service and Data Agent runtime image references and digests from the 7.0 delivery manifest, together with the pinned OpenSandbox images and Kubernetes components. In offline or private networks, mirror those pinned images and confirm that sandbox workers can pull them.
3. **Install OpenSandbox for the deployment type.** See [Docker Compose deployment](#linux-package-ansible-and-docker-compose-deployment) for Linux package, Ansible, or HENGSHI Compose installations, and [Kubernetes installation order](#kubernetes-and-helm-installation-order) for Kubernetes / Helm.
4. **Configure the HENGSHI service.** Configure the lifecycle URL, API credential, matching runtime image, and persistent session key for every JVM that handles Data Agent requests. Use the configuration entry point for the Linux package, containers, or Chart. For a split deployment, do not use `localhost` as the remote service address.
5. **Verify each link in order.** From the network of the HENGSHI JVM, BI container, or BI Pod, check service health and API authentication, then check HENGSHI capabilities, and finally run a real Data Agent job. A successful `/health` response or Pod Ready status proves process readiness only, not end-to-end connectivity; see [cross-host verification](#split-deployment-verification).

Before deployment, check the 7.0 delivery materials for image digests, supported architectures, checksums, and runtime-guide version. Record these with Secret sources, network policy, capacity, upgrade / rollback, and backup / recovery results.

## System and artifact prerequisites

For the HENGSHI service baseline, see [Installation environment](enviroment.md). The OpenSandbox environment also provides:

| Environment | Baseline and scope |
| --- | --- |
| Docker backend | Docker Engine and Docker Compose versions meet the 7.0 Data Agent runtime guide; Docker Compose 2.23.1 or later. Sandbox nodes run Linux OCI containers and can access the Docker socket |
| Linux kernel and networking | Sandbox hosts or Kubernetes workers must provide nftables / netfilter, container networking, and the permissions required by egress. The current 7.0 configuration uses `dns+nft`; the reference deployment uses Linux 5.10 or later as its baseline, while a tested Linux 3.10 environment cannot start egress. Distribution backports vary, so a version number alone is not sufficient. Check `uname -r`, nftables, and container networking, then verify egress with a real sandbox job. |
| Kubernetes backend | Kubernetes 1.21.1+; matching CRDs / controller, Linux worker nodes, image access, Pod networking, and RBAC |
| OpenSandbox server installation | The 7.0 Data Agent runtime package deploys Server as a container; the Docker host or Kubernetes node does not need a separate server-language runtime |
| CPU architecture and images | The current 7.0 Data Agent runtime image is Linux/amd64. Before using another architecture, confirm matching images exist for the HENGSHI runtime and all OpenSandbox components, then complete integration acceptance |
| Windows / macOS | Install the main service with its platform guide; run the Agent runtime in a Linux container environment prepared for the site |
| Capacity | Each Agent sandbox uses 2 vCPU and 2048 MiB; reserve capacity for the lifecycle service, controller, credential proxy, and idle pool according to concurrency, then size through load testing |

The version numbers follow the [OpenSandbox installation requirements](https://open-sandbox.ai/getting-started/installation). Use the 7.0 delivery package's qualification record for the final distribution, kernel, container-runtime, and architecture matrix.

### Offline deliverables

For offline or private-network environments, delivery provides two matching sets of material:

* **Image bundle**: contains the pinned images required by the 7.0 Data Agent runtime, imported into the customer's image registry before deployment.
* **Deployment files**: Docker Compose and Kubernetes / Helm configurations generated for the same delivery batch, with matching image references and runtime parameters.

Delivery provides the object-storage download location and checksums for both. Do not replace image references in the deployment files or switch to movable tags; if the image bundle and deployment files do not match, reconcile them against the delivery manifest before deploying.

## Networking, permissions, and persistence

* **Main service to OpenSandbox:** provide lifecycle API, execution, upload, and event-stream paths with service authentication; use TLS and controlled networking across hosts and in production.
* **OpenSandbox to the container platform:** Docker deployments require access to the local Docker socket; Kubernetes deployments require access to the Kubernetes API resources in the runtime namespace. Docker socket access is equivalent to host-administrator access, so restrict access to the runtime host and its configuration files.
* **Main service to sandbox endpoints:** in addition to the lifecycle API, HENGSHI must reach the sandbox execution address returned by the runtime. Across hosts, allow the required endpoint ports and verify that the returned host, port, and proxy path are reachable from the HENGSHI network.
* **Sandbox to models and HENGSHI APIs:** provide DNS, routes, certificates, and proxy rules for both endpoints. HBI uses the system service URL by default; set `CHATBI_AGENT_HBI_HOST` when a sandbox-reachable internal URL is required.
* **Credential proxy:** enable Credential Proxy, configure the egress image and `dns+nft` mode, and allow the required outbound targets. Apply a consistent network policy and proxy path to sandbox Pods. See [OpenSandbox Credential Vault](https://open-sandbox.ai/guides/credential-vault).
* **Kubernetes permissions:** have the cluster administrator install CRDs / controller. Run the lifecycle service with a dedicated ServiceAccount and the delivered RBAC for sandbox, Pod, and Service resources; configure the egress capabilities required by the admission policy.
* **Persistence and recovery:** OpenSandbox state uses the SQLite file and Docker volume / Kubernetes persistent volume configured by the runtime package. HENGSHI multi-turn sessions use PostgreSQL and MinIO / S3 for conversation records and encrypted checkpoints. These are separate data stores; retain and back them up according to their respective operations procedures. All HENGSHI service replicas use the same persistent session encryption key.
* **Offline environments:** prepare the matching images, manifests, CRDs, and certificates and make them available to target nodes. Agent images contain the matching HBI and built-in skills. Provide a Responses model service reachable from the sandbox.

## External service connection

The deployment administrator prepares OpenSandbox with credential injection and network isolation, then supplies the following variables to every HENGSHI service JVM. This table defines the connection contract.

| Variable | Purpose |
| --- | --- |
| `CHATBI_AGENT_SANDBOX_PROVIDER` | Set to `opensandbox` |
| `CHATBI_AGENT_SANDBOX_SERVER_URL` | HTTP(S) base URL of the OpenSandbox lifecycle service |
| `CHATBI_AGENT_SANDBOX_SERVER_TOKEN` | API credential matching the lifecycle service, injected through a Secret or controlled configuration |
| `CHATBI_AGENT_SANDBOX_IMAGE` | Agent OCI image matching the delivery version; pin the digest from the same delivery manifest in production |
| `CHATBI_AGENT_CODEX_SESSION_KEY` | Base64-encoded random 32-byte session encryption key; keep it consistent across replicas and after restarts |
| `CHATBI_AGENT_HBI_HOST` | Optional sandbox-reachable HENGSHI API URL; the system service URL is used when omitted. It does not need to be public, but must be reachable from the sandbox network |
| `CHATBI_AGENT_MAX_CONCURRENT_JOBS` | Optional per-JVM concurrent Agent job limit, planned with platform capacity |
| `CHATBI_AGENT_SANDBOX_POOL_MAX_IDLE` | Optional shared idle-sandbox target, default 5; set to 0 to create a sandbox per request. Pool state is stored in Redis; when Redis is unavailable the service only logs a warning and falls back to creating a sandbox per request |

1. **Traditional Linux package:** use `export` in `conf/hengshi-sense-env.sh` and the 7.0 package's environment-variable convention; inject sensitive values through controlled deployment configuration with restricted read access. Sandbox mode, provider, Server URL, and runtime image can use the corresponding `HS_DATA_AGENT_*` compatibility variables; the API token and session key use `CHATBI_AGENT_SANDBOX_SERVER_TOKEN` and `CHATBI_AGENT_CODEX_SESSION_KEY`.
2. **Ansible cluster:** configure the same service URL, credential, runtime image, and session key on every HENGSHI service node. Deploy OpenSandbox as a separate runtime; Ansible does not start another copy on each node.
3. **Containers / Kubernetes:** inject `CHATBI_AGENT_*` values through the container environment, ConfigMaps, and Chart values; store sensitive values in Secrets. Recreate containers or roll HENGSHI Pods after changes.

See [Configuration files](install-configure.md) for the configuration entry point. Model endpoints, names, and keys remain in [Responses model profiles](ai_models.md), separate from the sandbox lifecycle URL.

### Enablement checks and common misconfiguration

Updating `CHATBI_AGENT_SANDBOX_IMAGE` alone does not deploy or enable the lifecycle service; that variable only selects the sandbox image used for each job. Enablement also requires the provider, lifecycle URL, API credential, and session key, and the lifecycle service itself must be healthy.

When authenticated `GET /api/chatbi/headless/capabilities` returns `available:false`, use `unavailableReason`:

* `SANDBOX_RUNTIME_UNAVAILABLE`: the connection contract is incomplete (provider, URL, token, or session key is missing), or the lifecycle service is not deployed or unreachable. Setting `CHATBI_AGENT_SANDBOX_IMAGE` does not rule this out.
* `MODEL_PROFILE_UNAVAILABLE`: the sandbox runtime is ready but no usable Responses model profile is configured; complete [Responses model profiles](ai_models.md).
* Sandbox creation returns `SANDBOX::INVALID_PARAMETER: egress.image must be configured when networkPolicy is provided`: a single-host Docker deployment has no `[egress].image`; add the egress image and `dns+nft` mode as described above, then restart the lifecycle service.
* A job fails within seconds with `SANDBOX_AGENT_FAILED` and the main-service log shows `OpenSandbox data-plane request failed` (for example, `POST /pty` returns `{"error":"bad request"}`): the endpoint host or port returned by the lifecycle service does not match the address the main service uses. Check whether `[server] eip` is a bare IP or omits the service port or proxy path. For direct access, normally leave `eip` unset; if a reverse proxy needs a fixed advertised address, provide the complete base URL including scheme, host, port, and path, and confirm that the returned sandbox endpoint is reachable from the HENGSHI JVM.
* Sandbox creation keeps failing after the lifecycle service starts and the egress container restarts repeatedly: the host kernel does not support nftables / `dns+nft` redirection (common on kernel 3.10). Check the lifecycle service and egress logs, then move sandboxes to a supported modern-kernel host.
* The sandbox cannot reach the HENGSHI API while the capability check still returns `available:true`: the sandbox uses `CHATBI_AGENT_HBI_HOST`, or the system service address when it is omitted. When HENGSHI is served over HTTPS, check both: a certificate from a public CA requires the sandbox image to ship the public root certificates and the sandbox to resolve and reach that name (DNS, proxy, firewall); an internal or self-signed CA requires the sandbox image to trust that CA, see [Certificates for the sandbox-to-HENGSHI address](#sandbox-tls-trust).

### Certificates for the sandbox-to-HENGSHI address

The sandbox calls the HENGSHI API through `CHATBI_AGENT_HBI_HOST`, or the system service address when it is omitted. TLS trust is decided by the **sandbox image**: `HS_TRUST_CERTS_HOME` imports certificates only into the HENGSHI container's JDK truststore, and the sandbox image does not inherit it.

Decide which case applies first:

| HENGSHI address | What to do |
| --- | --- |
| `http://internal-address:port` | No certificate work; just confirm the sandbox can reach the address |
| `https://public-name` with a trusted certificate in the browser | No derived image; confirm the sandbox can reach the name over the network |
| `https://internal-name`, or the browser warns about the certificate | Derive the image and install the company CA |

To tell them apart, open HENGSHI in a browser and inspect the certificate issuer: DigiCert, Let's Encrypt and similar mean the second row; a company name or "self-signed" means the third.

**Public CA**: the runtime image is Debian-based with `ca-certificates` installed, so public roots are present. Only confirm that the sandbox can resolve and reach the address (DNS, proxy, firewall).

**Internal or self-signed CA**: derive the runtime image, add the CA to its trust chain, and point `CHATBI_AGENT_SANDBOX_IMAGE` at the derived image. Export the certificate first from a machine that can reach the address:

```bash
openssl s_client -connect bi.example.com:443 -servername bi.example.com </dev/null 2>/dev/null \
  | openssl x509 -outform PEM > corp-root-ca.crt
# Confirm it is the right certificate: the issuer should be the company CA
openssl x509 -in corp-root-ca.crt -noout -issuer -subject
```

```dockerfile
FROM <data-agent-runtime from the same batch>@sha256:<digest from the delivery manifest>
USER root
COPY corp-root-ca.crt /usr/local/share/ca-certificates/corp-root-ca.crt
RUN update-ca-certificates
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt \
    NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
USER agent
```

```bash
docker build -t <private-registry>/data-agent-runtime:7.0-corp .
docker push <private-registry>/data-agent-runtime:7.0-corp
# Take the immutable reference of the derived image for CHATBI_AGENT_SANDBOX_IMAGE
docker inspect --format '{{index .RepoDigests 0}}' <private-registry>/data-agent-runtime:7.0-corp
```

Verify it yourself right after the build instead of waiting for a failed question:

```bash
# 1) Host-to-HENGSHI reachability (network and DNS)
curl -sSI https://bi.example.com | head -1
# Expected: HTTP/2 200

# 2) Whether the derived image trusts the certificate (system trust store inside the image)
docker run --rm <derived-image> openssl s_client \
  -connect bi.example.com:443 -servername bi.example.com </dev/null 2>/dev/null \
  | grep 'Verify return code'
# Expected: Verify return code: 0 (ok)
```

A non-zero code from the second command means the CA is not in the trust chain. When both pass, run one real question in BI for the final confirmation.

> The runtime image has no `curl`; use `openssl` as above, which ships with `ca-certificates`.

Constraints:

* `FROM` must be the pinned digest of the runtime image from the same batch; an older base fails the capability-manifest check closed.
* Keep the original `USER agent`, `WORKDIR /home/agent` and entrypoint; do not run the sandbox as root.
* Derive again for every runtime image upgrade and update `CHATBI_AGENT_SANDBOX_IMAGE` together.
* For a Docker Compose host without a private registry, the local tag of the derived image is enough; Kubernetes deployments must push it to a registry the cluster can pull from.

## Linux package, Ansible, and Docker Compose deployment

The HENGSHI service installation differs across Linux package, Ansible, and Docker Compose deployments, but each uses a separate OpenSandbox Docker Compose project. In an Ansible cluster, all HENGSHI nodes normally connect to one runtime; Ansible distributes HENGSHI connection settings and does not start an OpenSandbox instance on every node.

1. **Choose the runtime host.** If the HENGSHI VM meets the Linux, container-network, and `dns+nft` requirements, Docker can run on the same host. Otherwise, keep HENGSHI unchanged and run OpenSandbox and sandbox containers on a dedicated Linux Docker host that meets the requirements. Linux 3.10 has been verified not to start the current egress configuration.

2. **Prepare the 7.0 runtime package.** Use `.env.example` and the Compose files in `data-agent/docker-compose/`. Set a unique, stable `AGENT_DOCKER_NETWORK`, a strong random `OPENSANDBOX_SERVER_API_KEY`, and `SANDBOX_PUBLISH_HOST` to the actual Docker bridge gateway on that host; do not reuse the example gateway. The package pins Server, execd, and egress image digests. Get the HENGSHI Data Agent runtime image digest from the same 7.0 delivery manifest.

3. **Set the API address.** Compose publishes the API on `127.0.0.1:8080` by default. A HENGSHI process on the same host can use the loopback address; a HENGSHI container on the same Docker control network uses `http://opensandbox-server:8080`. For a HENGSHI host elsewhere, set `OPENSANDBOX_API_BIND_ADDRESS` to a controlled private address on the sandbox host and restrict its firewall sources. Do not expose the API or sandbox execution ports to the public internet.

4. **Validate and start the runtime.** In the runtime-package directory, create and edit `.env`, protect its permissions, then run:

   ```bash
   cd data-agent/docker-compose
   test -f .env || cp .env.example .env
   chmod 600 .env
   docker network inspect bridge --format '{{(index .IPAM.Config 0).Gateway}}'
   # Put the returned gateway address in .env as SANDBOX_PUBLISH_HOST
   docker compose config -q
   docker compose up -d --wait
   ```

   When HENGSHI also runs in Docker Compose on the same host, apply `docker-compose.bi-overlay.yaml` to connect its container to the OpenSandbox control network, and set the service name and connection values using `bi-agent.env.example`. In a container, `localhost` refers only to that container. Keep the `opensandbox-store` volume across routine restarts and upgrades.

5. **Configure the HENGSHI service.** Set the lifecycle URL, matching API credential, runtime image, and session key for every HENGSHI service replica. Traditional Linux packages use `conf/hengshi-sense-env.sh`; sandbox mode, provider, Server URL, and runtime image can use `HS_DATA_AGENT_*` compatibility variables, while the API token and session key use `CHATBI_AGENT_SANDBOX_SERVER_TOKEN` and `CHATBI_AGENT_CODEX_SESSION_KEY`. Containers inject `CHATBI_AGENT_*` values directly. `CHATBI_AGENT_SANDBOX_SERVER_TOKEN` must match `OPENSANDBOX_SERVER_API_KEY`. Keep the session key on the HENGSHI side and share it across replicas.

### Cross-host networking and verification

An accessible OpenSandbox API does not by itself prove that a sandbox job can run. Confirm that each link below is reachable and restrict access to trusted sources:

| Link | Check |
| --- | --- |
| HENGSHI JVM → OpenSandbox API | `CHATBI_AGENT_SANDBOX_SERVER_URL` uses a host and port reachable from HENGSHI; credentials match; use TLS and access controls across hosts |
| HENGSHI JVM → sandbox endpoint | The endpoint host, port, and proxy path returned by OpenSandbox are reachable from the HENGSHI network; do not test only from the sandbox host or a laptop |
| OpenSandbox → container platform | Docker requires the local Docker socket; Kubernetes requires API access in the runtime namespace |
| Sandbox → HENGSHI API / model | The sandbox resolves and reaches `CHATBI_AGENT_HBI_HOST`, the Responses model endpoint, and destinations allowed by the credential proxy; a split deployment cannot use a loopback address local to HENGSHI |
| Sandbox host → registry | The sandbox host can pull runtime and OpenSandbox images by their pinned digests |

Verify in this order:

1. From the network path used by the HENGSHI JVM, request `<server-url>/health`; expect HTTP 200. Do not test only from the sandbox host or an operator workstation.

2. From the same path, call the authenticated `/v1/sandboxes?pageSize=1` API with the `OPEN-SANDBOX-API-KEY` header; expect HTTP 200 and JSON. Supply the credential through a protected environment variable or secret manager, not shell history.

   ```bash
   curl --fail --silent --show-error "$CHATBI_AGENT_SANDBOX_SERVER_URL/health"
   curl --fail --silent --show-error \
     -H "OPEN-SANDBOX-API-KEY: $SANDBOX_TOKEN" \
     "$CHATBI_AGENT_SANDBOX_SERVER_URL/v1/sandboxes?pageSize=1"
   ```

3. Check authenticated `GET /api/chatbi/headless/capabilities` and `unavailableReason`. `available: true` also requires a Data Agent license and a usable Responses model profile.

4. Submit a real question. Confirm that the runtime creates or assigns a sandbox, a tool call completes, and the sandbox can reach the HENGSHI API and model service. If a sandbox starts but the job fails, inspect lifecycle-service and egress logs and confirm that the returned endpoint address is reachable from the HENGSHI JVM.

Drain running jobs before restarting or upgrading OpenSandbox, then repeat the API and real-job checks. Keep the API credential unchanged where possible; if it must rotate, update both sides together. When moving the sandbox host, update the HENGSHI service URL, verify the endpoint contract, and only then switch traffic. Remove old-host containers after confirming no jobs remain.

## Kubernetes and Helm installation order

1. **Confirm cluster requirements.** Check Kubernetes version, Linux sandbox workers, CNI, image-pull access, network policy, and a bindable persistent volume. Workers using `dns+nft` need the required kernel and network permissions.
2. **Install cluster-level components.** The platform administrator installs the base, CRDs, and controller at the version pinned by the 7.0 runtime package. Install one set per cluster and verify that the CRDs are Established and the controller is Ready.
3. **Deploy the Data Agent runtime.** Install the runtime package's `data-agent/kubernetes/helm/data-agent` Chart in a dedicated namespace. It creates the lifecycle Server, ServiceAccount, RBAC, ClusterIP Service, and SQLite persistent volume. Create the runtime API credential in a Secret.
4. **Connect HENGSHI.** The HENGSHI Chart configures a connection; it does not install cluster-level CRDs or the controller. Set `dataAgent.enabled`, `serverUrl`, `runtimeImage`, and the Secret values from the runtime package. Kubernetes Secrets cannot be referenced across namespaces, so provision the API credential in both namespaces as instructed. Inject `CHATBI_AGENT_CODEX_SESSION_KEY` only into HENGSHI and keep it identical across replicas.
5. **Verify network and application flow.** From the BI Pod's network, check service health and an authenticated API request, then submit a real question and verify sandbox creation, HBI API / model access, and tool calls. If HENGSHI runs outside the cluster, a ClusterIP is not reachable directly from its VM; have the platform administrator provide a private HTTPS endpoint and verify that sandbox endpoints are also reachable from HENGSHI.

The 7.0 runtime package's `data-agent/kubernetes/README.md` contains pinned versions, Secret creation, Helm commands, and acceptance checks. Use HENGSHI images, runtime images, and OpenSandbox components from the same delivery batch.

### HENGSHI Chart configuration

The 7.0 BI Chart connects to an independently managed Data Agent runtime through `dataAgent`. Use the values reference from the same delivery package for exact key names:

| BI Chart `dataAgent` value | Purpose |
| --- | --- |
| `enabled` | Enable the Data Agent connection; default `false` |
| `serverUrl` | HTTP(S) address of the lifecycle server |
| `runtimeImage` | Agent runtime image matching 7.0 and pinned by digest |
| `existingSecret` + `tokenSecretKey` | Inject the lifecycle API token from a Secret in the BI namespace |
| `sessionSecretKey` | Inject the persistent session encryption key from the same BI Secret |
| `hbiHost` | Optional sandbox-reachable HENGSHI API URL override |
| `maxConcurrentJobs` / `poolMaxIdle` | Per-JVM concurrency limit and shared idle-sandbox target; defaults are 2 and 5 |

The runtime release stores its lifecycle API credential in a dedicated Secret; the BI release stores the session encryption key in the BI Secret. Pin every image to the digest in the delivery manifest and record upgrades by component version.

## Upgrading from 6.x to 7.0

This section is written for customer success and on-site operators: every step states **which command to run → what you should see → what to do when it does not match**. Commands assume a single-host Docker Compose deployment; see [Kubernetes and Helm upgrade](#kubernetes-upgrade) for the differences. Replace every `<...>` with the value for the site.

### Five terms to know first

| Term | What it is |
| --- | --- |
| HENGSHI main service (`hengshi` container) | The BI pages you normally open; upgrading to 7.0 upgrades it. |
| OpenSandbox lifecycle service | A separate set of containers added in 7.0 that creates a temporary sandbox for each data agent task. It is a separate release unit from the main service. |
| Data agent runtime image | The `data-agent-runtime` image that actually runs tasks inside a sandbox; shipped with the 7.0 package. |
| `BI_AGENT_ENV_FILE` | The absolute path of a plain text file that holds the eight connection settings. It is not a system file and not a variable in the main service `.env`; the site creates the file and points the main service at it at startup. |
| Three paths | The HENGSHI install directory (with `docker-compose.yaml`), `data-agent/docker-compose/` in the delivery package, and `/etc/hengshi/data-agent/` used throughout this section. |

### 1. Pre-upgrade checks

Run each check; do not continue until all of them pass.

#### 1.1 Confirm the host and Docker

```bash
hostname
docker version --format '{{.Server.Version}}'
docker compose version
```

Expected: `Server.Version` is 20.10 or later, Compose is 2.23.1 or later, and none of the commands fail. On `permission denied`, add `sudo` or ask operations to add the current user to the `docker` group and log in again.

#### 1.2 Find the HENGSHI install directory

```bash
docker ps --format '{{.Names}}  {{.Image}}' | grep -i hengshi
# Use the container name printed above in the next command
docker inspect <hengshi-container> --format '{{index .Config.Labels "com.docker.compose.project.working_dir"}}'
```

Expected: a directory such as `/opt/hengshi`, which contains `docker-compose.yaml` and `.env`. If there is no compose file, this is not the deployment host; move to the deployment host.

#### 1.3 Back up first

```bash
cd /opt/hengshi
cp .env .env.bak.$(date +%F)
ls -l .env.bak.*
```

Expected: an `.env.bak` file with today's date. Back up metadb and MinIO with the customer's existing process, and confirm the rollback package is at hand.

#### 1.4 Confirm the 7.0 image and the runtime images are loaded

```bash
docker images --digests | grep -E 'hengshi-sense|data-agent-runtime|opensandbox'
```

Expected: one `hengshi-sense` 7.0 image plus `data-agent-runtime`, `opensandbox-server`, `opensandbox-execd` and `opensandbox-egress`. If any is missing, first run [2.1 Import offline images](#import-offline-images) and repeat this check.

#### 1.5 Confirm the ports are free

```bash
ss -lntp | grep -E ':(8080|80|443)\s' || echo 'port free'
```

Expected: no output for 8080, or only the process you expect. If 8080 is taken, change `OPENSANDBOX_API_PORT` in the step 2 `.env` and change the port in `CHATBI_AGENT_SANDBOX_SERVER_URL` in step 4 to the same value.

#### 1.6 Confirm compose renders (this starts nothing)

```bash
cd /opt/hengshi
docker compose config -q; echo "exit=$?"
```

Expected: `exit=0`. Fix any error before continuing.

#### 1.7 Check the sandbox host kernel (when the sandbox runs on this host)

```bash
uname -r
nft --version
```

Expected: kernel 5.10 or later and the `nft` command is available. Otherwise deploy OpenSandbox on another supported Linux host, run step 2 there, and change `SERVER_URL` in step 4 to that host's internal address.

### 2. Deploy the lifecycle service (runtime side)

This side creates sandboxes. Get it running before configuring the main service.

#### 2.1 Import offline images

When the host cannot reach the internet or the image registry, use the delivery batch `data-agent-runtime-bundle-cli-<sha12>-amd64.zip`. It contains five `docker save` artifacts (`data-agent-runtime`, `opensandbox-server`, `opensandbox-execd`, `opensandbox-egress`, `opensandbox-controller`), `manifest.json` and a whole-bundle `.sha256`.

```bash
cd <7.0-delivery-package>
sha256sum -c data-agent-runtime-bundle-cli-<sha12>-amd64.zip.sha256
unzip -q data-agent-runtime-bundle-cli-<sha12>-amd64.zip -d bundle
cd bundle
for f in *.tar.gz; do docker load -i "$f"; done
docker images --digests | grep -E 'data-agent-runtime|opensandbox'
```

Expected: the checksum passes and four runtime images are visible (`opensandbox-controller` is used only on Kubernetes). `docker load` restores both tags and digests; if you retag, keep the `@sha256:` digest and update the three `OPENSANDBOX_*_IMAGE` values in `.env` and `CHATBI_AGENT_SANDBOX_IMAGE` on the main service side. Do not use movable tags such as `develop`.

#### 2.2 Generate the two secrets

```bash
cd <7.0-delivery-package>/data-agent/docker-compose
ls
head -c 48 /dev/urandom | base64     # 1) lifecycle API credential
head -c 32 /dev/urandom | base64     # 2) session key
```

Expected: the directory contains `.env.example`, `docker-compose.yaml` and `docker-compose.bi-overlay.yaml`; each command prints one random string. Value 1 must be identical in steps 2.3 and 4.2. Value 2 must be reused for upgrades, scaling and rollback; losing it makes existing conversations unrecoverable. Store both in a password manager immediately.

#### 2.3 Create the runtime `.env`

```bash
cp .env.example .env
chmod 600 .env
docker network inspect bridge --format '{{(index .IPAM.Config 0).Gateway}}'
```

Set these five lines to site values and keep the remaining defaults:

```bash
OPENSANDBOX_SERVER_API_KEY=<value 1 from step 2.2>
AGENT_DOCKER_NETWORK=hengshi-data-agent-controlplane
SANDBOX_PUBLISH_HOST=<gateway printed by the previous command, for example 172.17.0.1>
OPENSANDBOX_API_BIND_ADDRESS=127.0.0.1
OPENSANDBOX_API_PORT=8080
```

Format: one `KEY=VALUE` per line, no spaces around `=`, no quotes and no `export`; `#` starts a comment. On an offline host, also uncomment the three `OPENSANDBOX_*_IMAGE` values at the end of the file and point them at the images from 2.1; otherwise startup tries to pull upstream images.

#### 2.4 Validate and start the lifecycle service

```bash
docker compose config -q; echo "exit=$?"
docker compose up -d --wait
docker compose ps
```

Expected: `exit=0`; `opensandbox-server` is running (or healthy) in `ps`, with no Restarting / Exit.

#### 2.5 Verify with the token

```bash
export SANDBOX_URL=http://127.0.0.1:8080
export SANDBOX_TOKEN='<value 1 from step 2.2>'
curl -fsS "$SANDBOX_URL/health"; echo
curl -fsS -H "OPEN-SANDBOX-API-KEY: $SANDBOX_TOKEN" "$SANDBOX_URL/v1/sandboxes?pageSize=1"; echo
```

Expected: the first call returns health information; the second returns JSON (an items list, possibly empty), not 401/403. A 401 means `SANDBOX_TOKEN` and `OPENSANDBOX_SERVER_API_KEY` differ; set the same value and restart the service.

### 3. Upgrade the HENGSHI main service image (no data agent yet)

This step upgrades only the main service. Confirm existing features work before connecting the data agent.

#### 3.1 Point the image tag at 7.0

```bash
cd /opt/hengshi
# Edit .env and set HS_IMAGE_TAG to the tag in the 7.0 delivery list
grep '^HS_IMAGE_TAG=' .env
```

Expected: the 7.0 tag. Keep the existing `HS_*`, `DATA_GATEWAY_*`, `MINIO_*` and `VECTOR_*` values. If the image base OS changed, run `REINDEX DATABASE hengshi` for the built-in PostgreSQL as described in [built-in PostgreSQL when the image OS changes](deployment-upgrade-faq.md), then restore traffic.

#### 3.2 Recreate the main service and confirm existing features

```bash
docker compose -f docker-compose.yaml up -d hengshi
docker compose -f docker-compose.yaml ps hengshi
```

Expected: `hengshi` is running; you can sign in and existing dashboards, charts and permissions work. If it does not start, roll back the image tag to 6.3 as described in [Rollback](#upgrade-rollback), confirm recovery, and only then continue.

### 4. Configure the main service side (`BI_AGENT_ENV_FILE`)

`BI_AGENT_ENV_FILE` is not a built-in file and not a variable in the main service `.env`. It is an environment variable exported when starting the main service, whose value points at a text file you create; `docker-compose.bi-overlay.yaml` injects that file into the `hengshi` container through `env_file`. This section uses `/etc/hengshi/data-agent/bi-agent.env`.

#### 4.1 Confirm the variables are not set yet

```bash
docker exec <hengshi-container> printenv | grep '^CHATBI_AGENT_' || echo 'not configured yet'
```

Expected: `not configured yet` before the upgrade. If values already exist, confirm their source with the site before overwriting them.

#### 4.2 Create the file

```bash
sudo mkdir -p /etc/hengshi/data-agent
sudo tee /etc/hengshi/data-agent/bi-agent.env >/dev/null <<'EOF'
CHATBI_AGENT_SANDBOX_PROVIDER=opensandbox
CHATBI_AGENT_SANDBOX_SERVER_URL=http://opensandbox-server:8080
CHATBI_AGENT_SANDBOX_SERVER_TOKEN=<value 1 from step 2.2>
CHATBI_AGENT_SANDBOX_IMAGE=<data-agent-runtime@sha256:... from the delivery list>
CHATBI_AGENT_CODEX_SESSION_KEY=<value 2 from step 2.2>
CHATBI_AGENT_HBI_HOST=http://host.docker.internal:<HENGSHI exposed port>
CHATBI_AGENT_MAX_CONCURRENT_JOBS=2
CHATBI_AGENT_SANDBOX_POOL_MAX_IDLE=5
EOF
sudo chmod 600 /etc/hengshi/data-agent/bi-agent.env
```

Only four lines need careful confirmation:

* `CHATBI_AGENT_SANDBOX_SERVER_URL`: on a single Docker host always use `http://opensandbox-server:8080`; do not use `127.0.0.1` or the host IP.
* `CHATBI_AGENT_SANDBOX_SERVER_TOKEN`: exactly the `OPENSANDBOX_SERVER_API_KEY` from step 2.3.
* `CHATBI_AGENT_SANDBOX_IMAGE`: the `@sha256:` image from the delivery list; do not use movable tags such as `develop` or `latest`.
* `CHATBI_AGENT_CODEX_SESSION_KEY`: value 2 from step 2.2, identical on every replica, and unchanged after the upgrade.

`CHATBI_AGENT_HBI_HOST` is the address the sandbox uses to reach HENGSHI and must not be `localhost`: on a single Docker host use `http://host.docker.internal:<HENGSHI exposed port>`; across hosts use an internal HENGSHI address or an operations-managed HTTPS domain. The same format rules apply: one `KEY=VALUE` per line, no spaces around `=`, no quotes and no `export`.

#### 4.3 Self-check the file (starts nothing)

```bash
sudo grep -c '^CHATBI_AGENT_' /etc/hengshi/data-agent/bi-agent.env
sudo grep '^CHATBI_AGENT_CODEX_SESSION_KEY=' /etc/hengshi/data-agent/bi-agent.env | cut -d= -f2 | base64 -d | wc -c
```

Expected: 8 from the first command and 32 from the second. Fix the format if not.

#### 4.4 Recreate the main service with the overlay

```bash
cd /opt/hengshi
export AGENT_DOCKER_NETWORK=hengshi-data-agent-controlplane
export BI_AGENT_ENV_FILE=/etc/hengshi/data-agent/bi-agent.env
docker compose -f docker-compose.yaml -f <7.0-delivery-package>/data-agent/docker-compose/docker-compose.bi-overlay.yaml config -q; echo "exit=$?"
docker compose -f docker-compose.yaml -f <7.0-delivery-package>/data-agent/docker-compose/docker-compose.bi-overlay.yaml up -d hengshi
docker compose -f docker-compose.yaml -f <7.0-delivery-package>/data-agent/docker-compose/docker-compose.bi-overlay.yaml ps hengshi
```

Expected: `config` prints `exit=0`; `ps` shows `hengshi` running; no `variable is not set` error.

Every later restart of the main service must include these two `export` lines and the `-f` overlay, otherwise the data agent configuration is not injected. Record them in the site startup script or runbook.

#### 4.5 Confirm the variables reached the container

```bash
docker exec <hengshi-container> printenv | grep '^CHATBI_AGENT_' | sed 's/=.*/=<set>/'
docker exec <hengshi-container> printenv CHATBI_AGENT_SANDBOX_SERVER_URL
```

Expected: eight variables from the first command and `http://opensandbox-server:8080` from the second. Fewer than eight means the `BI_AGENT_ENV_FILE` path is wrong or the overlay was not used.

#### 4.6 Confirm the main service can reach the lifecycle service

```bash
docker exec <hengshi-container> sh -c 'curl -fsS "$CHATBI_AGENT_SANDBOX_SERVER_URL/health" || wget -qO- "$CHATBI_AGENT_SANDBOX_SERVER_URL/health"'
```

Expected: health information. If it fails, confirm both sides use the same `AGENT_DOCKER_NETWORK` and the lifecycle service is running.

### 5. Acceptance

The full list is in [Post-deployment acceptance](#post-deployment-acceptance); an upgrade must complete at least these five checks.

#### 5.1 Capability state

Sign in with an account that has data agent permission, open a data agent conversation, and ask a question; a normal answer means the capability is available. To inspect the API field, run this in a signed-in browser:

```bash
curl -fsS -b '<cookie copied from the browser>' https://<HENGSHI-domain>/api/chatbi/headless/capabilities
```

Expected: `available: true`. If `false`, record `unavailableReason` and follow [Common failures](#upgrade-troubleshooting).

#### 5.2 New conversation, no scope selected

Example question: the top five categories by revenue in the last 30 days. Expected: a chart, a data-source explanation, and tool-call records in the conversation.

#### 5.3 Ask a follow-up in the same conversation

Expected: the question stays in the original conversation, no new conversation is created, and prior context is used.

#### 5.4 Restart the main service and ask again

```bash
docker restart <hengshi-container>
```

Expected: the old conversation can be opened and continued.

#### 5.5 Restart the lifecycle service and create a new task

```bash
cd <7.0-delivery-package>/data-agent/docker-compose
docker compose restart
```

Expected: a sandbox can still be created and the task completes; the `opensandbox-store` volume is not removed.

### 6. Upgrade completion criteria

All items must pass; follow [Common failures](#upgrade-troubleshooting) for any that do not:

* \[ ] The authenticated `GET /api/chatbi/headless/capabilities` returns `available:true`
* \[ ] A question without a selected scope returns a chart and data
* \[ ] A follow-up stays in the same conversation instead of creating a new one
* \[ ] After restarting the HENGSHI main service, the old conversation can still be read and continued
* \[ ] After restarting the lifecycle service, a sandbox can still be created and tasks complete (`opensandbox-store` volume intact)
* \[ ] Every result above comes from a real task, not just an open port or a running service

### 7. Common failures

* **`available:false` with `unavailableReason=SANDBOX_RUNTIME_UNAVAILABLE`**: run `docker exec <hengshi-container> printenv | grep CHATBI_AGENT_` to confirm all eight variables, then `docker compose ps` in the runtime package directory to confirm the lifecycle service is running; fill in what is missing.
* **Lifecycle API returns 401**: compare `OPENSANDBOX_SERVER_API_KEY` in `.env` with `CHATBI_AGENT_SANDBOX_SERVER_TOKEN` in `/etc/hengshi/data-agent/bi-agent.env`; set the same value and restart both sides.
* **Sandbox creation fails with the host address unavailable**: rerun `docker network inspect bridge --format '{{(index .IPAM.Config 0).Gateway}}'`, write the output to `SANDBOX_PUBLISH_HOST` in `.env`, and restart.
* **`available:true` but tasks fail and the sandbox cannot reach HENGSHI**: confirm `CHATBI_AGENT_HBI_HOST` is reachable from the sandbox, then follow [Certificates for the sandbox-to-HENGSHI address](#sandbox-tls-trust).
* **Driver error on first startup**: confirm the old `HENGSHI_JDBC_CONFIG` was not deleted early; do not delete it before the first startup completes.
* **Old conversations cannot be opened after a restart**: confirm `CHATBI_AGENT_CODEX_SESSION_KEY` did not change and run `docker volume ls | grep opensandbox` to confirm the state volume exists.

### 8. HTTPS and certificates

Decide which case applies:

* An internal `http://` address: no certificate work; just confirm the sandbox can reach it.
* An `https://` address whose certificate is trusted by the browser (public CA): no derived image; confirm the sandbox can reach the domain.
* An `https://` address the browser does not trust, or one signed by a company CA: install the company CA into the runtime image.

See [Certificates for the sandbox-to-HENGSHI address](#sandbox-tls-trust) for the decision method, certificate export, derived-image build and self-check commands. Rederive the image for every runtime image upgrade.

### 9. Rollback

Rollback touches only the main service image and connection settings; it does not affect state held by the lifecycle service:

```bash
cd /opt/hengshi
# Set HS_IMAGE_TAG in .env back to the 6.3 image
docker compose -f docker-compose.yaml up -d hengshi   # no overlay
docker compose ps hengshi
```

Expected: 6.3 starts normally. The lifecycle service can stay deployed; when it is no longer needed, run `docker compose stop` in the runtime package directory. Do not use `down -v` and do not remove the `opensandbox-store` volume. Do not regenerate the session key; a later upgrade can still recover old conversations.

### 10. Kubernetes and Helm upgrade

Kubernetes uses the same component order as Docker Compose, with two Helm release units. Run these commands from the 7.0 delivery package root; the examples assume runtime namespace `agent-runtime` and BI namespace `bi-prod`, and chart paths and value names follow the delivery package.

#### 10.1 Check cluster prerequisites

```bash
kubectl version --short
kubectl get nodes -o wide
kubectl get storageclass
```

Expected: Kubernetes 1.21.1 or later; worker nodes meet the Linux 5.10+ and egress requirements; at least one bindable RWO StorageClass (the runtime defaults to 2Gi).

#### 10.2 Create namespaces and Secrets

```bash
export RUNTIME_NS=agent-runtime BI_NS=bi-prod
kubectl create namespace "$RUNTIME_NS" --dry-run=client -o yaml | kubectl apply -f -
kubectl create namespace "$BI_NS" --dry-run=client -o yaml | kubectl apply -f -
umask 077
openssl rand -base64 32 | tr -d '\n' > codex-session-key
test "$(openssl base64 -d -A -in codex-session-key | wc -c | tr -d ' ')" = 32
# server-token is written by the managed secret store; never echo it
kubectl -n "$RUNTIME_NS" create secret generic data-agent-runtime \
  --from-file=CHATBI_AGENT_SANDBOX_SERVER_TOKEN=server-token --dry-run=client -o yaml | kubectl apply -f -
kubectl -n "$BI_NS" create secret generic data-agent-bi \
  --from-file=CHATBI_AGENT_SANDBOX_SERVER_TOKEN=server-token \
  --from-file=CHATBI_AGENT_CODEX_SESSION_KEY=codex-session-key --dry-run=client -o yaml | kubectl apply -f -
```

Expected: both Secrets are created; `server-token` is identical in both namespaces and the session key exists only in the BI namespace. Secrets cannot be referenced across namespaces; the session key and the runtime PVC together determine whether old conversations can be restored, so do not re-create them during upgrade or rollback.

#### 10.3 Install platform components (once per cluster)

The platform team installs base and controller from the fixed OpenSandbox release-1.1.1 commit; keep exactly one controller release per cluster.

```bash
export OPENSANDBOX_COMMIT=531700ca18a7fa5fab6a2f25d6dc68a76eddab12
export OPENSANDBOX_SRC=/srv/vendor/opensandbox-$OPENSANDBOX_COMMIT
git clone https://github.com/opensandbox-group/OpenSandbox.git "$OPENSANDBOX_SRC"
git -C "$OPENSANDBOX_SRC" checkout --detach "$OPENSANDBOX_COMMIT"
helm upgrade --install opensandbox-base "$OPENSANDBOX_SRC/manifests/charts/base" \
  --namespace opensandbox-system --set fastSandbox.namespaces.createSystem=false \
  --set fastSandbox.namespaces.create=false --wait
kubectl wait --for=condition=Established crd/batchsandboxes.sandbox.opensandbox.io --timeout=120s
helm upgrade --install opensandbox-controller "$OPENSANDBOX_SRC/manifests/charts/controller" \
  --namespace opensandbox-system -f <reviewed controller values> --wait
kubectl rollout status deployment/opensandbox-controller-manager -n opensandbox-system --timeout=180s
```

Expected: the CRD is Established and the controller deployment completes its rollout. If the namespace or CRD is already platform-managed, verify Helm ownership and versions first; never delete them to bypass a conflict.

#### 10.4 Deploy the lifecycle service

```bash
export AGENT_VALUES_FILE=<reviewed runtime values file>
export AGENT_SERVER_IMAGE=<mirrored opensandbox-server@sha256:...>
export AGENT_EXECD_IMAGE=<mirrored opensandbox-execd@sha256:...>
export AGENT_EGRESS_IMAGE=<mirrored opensandbox-egress@sha256:...>
helm lint ./data-agent/kubernetes/helm/data-agent
helm upgrade --install data-agent ./data-agent/kubernetes/helm/data-agent \
  --namespace "$RUNTIME_NS" -f "$AGENT_VALUES_FILE" \
  --set-string existingSecret=data-agent-runtime \
  --set-string images.server="$AGENT_SERVER_IMAGE" \
  --set-string images.execd="$AGENT_EXECD_IMAGE" \
  --set-string images.egress="$AGENT_EGRESS_IMAGE" \
  --set-string networkPolicy.clientNamespace="$BI_NS" --wait
export AGENT_URL="$(helm get notes data-agent --namespace "$RUNTIME_NS" | sed -n 's|^  \(http://.*\.svc:[0-9][0-9]*\)$|\1|p')"
printf '%s\n' "$AGENT_URL"
```

Expected: the release installs and `AGENT_URL` prints the in-cluster Service address. All three runtime images must come from the private registry and be pinned by digest; do not use upstream defaults or `develop` tags.

#### 10.5 Upgrade the HENGSHI Chart and connect the runtime

Keep `dataAgent.enabled=false` for the first Chart upgrade, confirm existing features, and only then enable the connection.

```bash
export BI_VALUES_FILE=<reviewed HENGSHI values file>
helm upgrade --install hengshi-sense ./kubernetes/helm/hengshi-sense --namespace "$BI_NS" \
  -f "$BI_VALUES_FILE" \
  --set-string hsImage.hengshi.address="<7.0 hengshi-sense@sha256:...>"
# dataAgent.enabled is still false above; after BI looks normal, run:
helm upgrade hengshi-sense ./kubernetes/helm/hengshi-sense --namespace "$BI_NS" -f "$BI_VALUES_FILE" \
  --set dataAgent.enabled=true \
  --set-string dataAgent.serverUrl="$AGENT_URL" \
  --set-string dataAgent.runtimeImage="<data-agent-runtime@sha256:...>" \
  --set-string dataAgent.existingSecret=data-agent-bi \
  --set-string dataAgent.tokenSecretKey=CHATBI_AGENT_SANDBOX_SERVER_TOKEN \
  --set-string dataAgent.sessionSecretKey=CHATBI_AGENT_CODEX_SESSION_KEY \
  --set dataAgent.maxConcurrentJobs=2 --set dataAgent.poolMaxIdle=5
```

Expected: both upgrades report deployed and the BI Pods roll out and can sign in.

Field mapping: `serverUrl` → `CHATBI_AGENT_SANDBOX_SERVER_URL`; `runtimeImage` → `CHATBI_AGENT_SANDBOX_IMAGE`; `existingSecret` + `tokenSecretKey` → `CHATBI_AGENT_SANDBOX_SERVER_TOKEN`; `existingSecret` + `sessionSecretKey` → `CHATBI_AGENT_CODEX_SESSION_KEY`; `hbiHost` → `CHATBI_AGENT_HBI_HOST`.

#### 10.6 Acceptance

```bash
kubectl -n "$RUNTIME_NS" get deploy,pvc
kubectl -n "$BI_NS" exec deploy/hengshi-sense -- sh -c 'command -v curl || command -v wget'
kubectl -n "$BI_NS" exec deploy/hengshi-sense -- sh -c \
  'curl -fsS -H "OPEN-SANDBOX-API-KEY: $CHATBI_AGENT_SANDBOX_SERVER_TOKEN" "$CHATBI_AGENT_SANDBOX_SERVER_URL/v1/sandboxes?pageSize=1"'
```

Expected: the runtime Deployment is Available and the PVC is Bound; the BI Pod receives JSON, not 401/403. If the BI image has neither curl nor wget, start a temporary diagnostic Pod in the BI namespace from a mirrored diagnostic image, with the BI ServiceAccount and the `hsrole=hengshi` label, run the same request, and delete the Pod afterwards.

Then complete the capability check, real questions, follow-ups and restart recovery from section 5; a Ready Pod or an open port alone is not acceptance.

#### 10.7 Upgrade and rollback cautions

Before upgrading, pause new tasks and drain running sandboxes and the idle pool. The lifecycle Server is a single-replica Recreate; its SQLite PVC (`helm.sh/resource-policy: keep`) must be retained and remounted.

```bash
helm history data-agent -n "$RUNTIME_NS"
helm rollback data-agent <previous revision> -n "$RUNTIME_NS"
helm rollback hengshi-sense <previous revision> -n "$BI_NS"
```

Expected: both releases roll back independently; the PVC, BI database/MinIO, session key and platform CRD/controller all remain. Drain tasks before uninstalling too; after `helm uninstall`, do not delete the retained SQLite PVC, BI data, session key, platform CRD/controller or namespaces.

### 11. Upgrade-period cautions

* `CHATBI_AGENT_CODEX_SESSION_KEY` together with the `opensandbox-store` volume determines whether existing conversations can be restored: keep the original key after the upgrade and never delete the volume.
* On environments that configured `HENGSHI_JDBC_CONFIG` in 6.x, do not delete it before the first 7.0 startup completes and custom data sources work; from 7.0 on, driver loading uses the unified cache, and the variable is only for migration from older environments.
* When HENGSHI is served over HTTPS (regardless of whether `CHATBI_AGENT_HBI_HOST` is set), confirm after the upgrade that the sandbox can resolve and reach the address and trust its certificate; see [Enablement checks and common misconfiguration](#enablement-checks).

## Post-deployment acceptance

1. Check the Data Agent license and runtime capability; authenticated `GET /api/chatbi/headless/capabilities` returns availability.
2. Configure a Responses model in system settings and test its connection.
3. Submit a real question and verify tool execution, chart delivery, and history readback; confirm that the sandbox can reach the model and HENGSHI API.
4. In a read-only conversation, request a resource change and confirm the service refuses it and suggests Act mode; in an Act conversation, count a change as complete only when a successful response identifies the affected resource.
5. For a question that needs several charts, confirm one answer renders all of them rather than only the last one.
6. Ask a follow-up, recreate the sandbox or restart the main service, and continue the conversation to verify persistence; check cancellation, timeout, and temporary sandbox reclamation.
7. Check active sandbox and idle-pool capacity at the expected concurrency, including direct creation when the idle pool is empty.

## Delivery record

The deployment record includes the 7.0 package / Compose / YAML / Chart versions and acquisition method, all OpenSandbox component versions and image architectures, the source and rotation method for each Secret, cross-host TLS and network-policy checks, concurrency capacity, upgrade/rollback and recovery results, and qualification conclusions for the target operating system, container runtime, and CPU architecture. Use this record to maintain the release support matrix and the customer-site delivery checklist.
