openclaw - 💡(How to fix) Fix Env vars from .env not passed to sandbox exec calls — generic provider placeholder not resolved [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#57427Fetched 2026-04-08 01:49:50
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
2
Author
Timeline (top)
commented ×1

Environment variables defined in ~/.openclaw/.env are not available inside sandbox exec calls. When a generic OpenShell provider is configured (e.g., ncbi with credential key NCBI_API_KEY), the env var inside the sandbox resolves to the OpenShell placeholder openshell:resolve:env:NCBI_API_KEY rather than the actual value.

It's unclear whether OpenClaw is responsible for passing the resolved env var value to OpenShell when creating the sandbox, or whether OpenShell's L7 proxy should resolve the placeholder. Filing here for the OpenClaw side of the issue.

Root Cause

Environment variables defined in ~/.openclaw/.env are not available inside sandbox exec calls. When a generic OpenShell provider is configured (e.g., ncbi with credential key NCBI_API_KEY), the env var inside the sandbox resolves to the OpenShell placeholder openshell:resolve:env:NCBI_API_KEY rather than the actual value.

It's unclear whether OpenClaw is responsible for passing the resolved env var value to OpenShell when creating the sandbox, or whether OpenShell's L7 proxy should resolve the placeholder. Filing here for the OpenClaw side of the issue.

Fix Action

Workaround

Hardcode the API key directly in skill files / curl URLs.

Code Example

{
  "env": {
    "shellEnv": {
      "enabled": true,
      "timeoutMs": 15000
    }
  },
  "plugins": {
    "entries": {
      "openshell": {
        "enabled": true,
        "config": {
          "from": "openshell/sandbox-from:1774813410",
          "providers": ["ncbi"]
        }
      }
    }
  }
}

---

NCBI_API_KEY=<redacted>

---

openshell provider create --name ncbi --type generic --credential NCBI_API_KEY

---

exec curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&api_key=$NCBI_API_KEY&term=test"
RAW_BUFFERClick to expand / collapse

Description

Environment variables defined in ~/.openclaw/.env are not available inside sandbox exec calls. When a generic OpenShell provider is configured (e.g., ncbi with credential key NCBI_API_KEY), the env var inside the sandbox resolves to the OpenShell placeholder openshell:resolve:env:NCBI_API_KEY rather than the actual value.

It's unclear whether OpenClaw is responsible for passing the resolved env var value to OpenShell when creating the sandbox, or whether OpenShell's L7 proxy should resolve the placeholder. Filing here for the OpenClaw side of the issue.

Setup

openclaw.json (relevant sections):

{
  "env": {
    "shellEnv": {
      "enabled": true,
      "timeoutMs": 15000
    }
  },
  "plugins": {
    "entries": {
      "openshell": {
        "enabled": true,
        "config": {
          "from": "openshell/sandbox-from:1774813410",
          "providers": ["ncbi"]
        }
      }
    }
  }
}

~/.openclaw/.env:

NCBI_API_KEY=<redacted>

OpenShell provider:

openshell provider create --name ncbi --type generic --credential NCBI_API_KEY

Gateway: running via systemd (user service), which has Environment=NCBI_API_KEY=<value> set.

Steps to reproduce

  1. Configure as above

  2. In a sandbox exec call, reference $NCBI_API_KEY in a curl URL:

    exec curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&api_key=$NCBI_API_KEY&term=test"
  3. The L7 proxy log shows the URL contains api_key=openshell:resolve:env:NCBI_API_KEY instead of the actual key.

Expected behavior

$NCBI_API_KEY should resolve to the real value inside sandbox exec calls — either:

  • OpenClaw passes the resolved value to OpenShell when creating the sandbox, or
  • OpenClaw instructs OpenShell to resolve the placeholder before the request leaves the proxy

Actual behavior

The placeholder openshell:resolve:env:NCBI_API_KEY is passed through unresolved.

Environment

  • OpenClaw: v2026.3.28 (gateway mode, systemd)
  • OpenShell: 0.0.16
  • Also filed as NVIDIA/OpenShell#668

Workaround

Hardcode the API key directly in skill files / curl URLs.

extent analysis

Fix Plan

To resolve the issue of environment variables not being available inside sandbox exec calls, we need to modify the OpenClaw configuration to pass the resolved environment variable values to OpenShell when creating the sandbox.

Step 1: Update OpenClaw Configuration

Update the openclaw.json file to include the env section with the shellEnv configuration. Specifically, add the passEnv option and set it to true to pass the environment variables to the sandbox.

{
  "env": {
    "shellEnv": {
      "enabled": true,
      "timeoutMs": 15000,
      "passEnv": true
    }
  },
  "plugins": {
    "entries": {
      "openshell": {
        "enabled": true,
        "config": {
          "from": "openshell/sandbox-from:1774813410",
          "providers": ["ncbi"]
        }
      }
    }
  }
}

Step 2: Restart OpenClaw Service

Restart the OpenClaw service to apply the updated configuration.

systemctl restart openclaw

Step 3: Verify Environment Variable Resolution

Verify that the environment variable NCBI_API_KEY is resolved correctly inside the sandbox exec call.

exec curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&api_key=$NCBI_API_KEY&term=test"

The api_key parameter in the URL should now be replaced with the actual value of the NCBI_API_KEY environment variable.

Verification

To verify that the fix worked, check the L7 proxy log to ensure that the api_key parameter in the URL is replaced with the actual value of the NCBI_API_KEY environment variable.

Extra Tips

  • Make sure to update the openclaw.json file correctly and restart the OpenClaw service to apply the changes.
  • If the issue persists, check the OpenClaw and OpenShell logs for any errors or warnings related to environment variable resolution.
  • Consider implementing additional logging or debugging mechanisms to monitor environment variable resolution and sandbox execution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

$NCBI_API_KEY should resolve to the real value inside sandbox exec calls — either:

  • OpenClaw passes the resolved value to OpenShell when creating the sandbox, or
  • OpenClaw instructs OpenShell to resolve the placeholder before the request leaves the proxy

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING