openclaw - 💡(How to fix) Fix Skill 环境变量未注入到 exec 子进程 [1 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#62370Fetched 2026-04-08 03:05:24
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Code Example

{
  "skills": {
    "tavily": {
      "enabled": true,
      "env": {
        "TAVILY_API_KEY": "tvly-xxx"
      }
    }
  }
}

---

node ~/.openclaw/skills/tavily-search/scripts/search.mjs "test"

---

export TAVILY_API_KEY="tvly-xxx"
RAW_BUFFERClick to expand / collapse

问题描述

openclaw.json 中配置的 skill 环境变量(如 skills.tavily.env.TAVILY_API_KEY)只在 Gateway 进程内部可用,通过 exec 工具启动的子进程无法继承这些环境变量。

复现步骤

  1. openclaw.json 中配置:
{
  "skills": {
    "tavily": {
      "enabled": true,
      "env": {
        "TAVILY_API_KEY": "tvly-xxx"
      }
    }
  }
}
  1. 运行 skill 脚本:
node ~/.openclaw/skills/tavily-search/scripts/search.mjs "test"
  1. 报错:Missing TAVILY_API_KEY

预期行为

skill 配置的环境变量应该自动注入到该 skill 相关的子进程执行环境中。

当前解决方案

手动将 API key 写入 ~/.zshrc

export TAVILY_API_KEY="tvly-xxx"

建议改进

在框架层面,当执行 skill 相关命令时,自动将 skills.<name>.env 中的环境变量注入到子进程环境中。可以通过:

  1. 修改 exec 工具,识别 skill 相关命令并自动注入 env
  2. 或在 skill 执行器中统一处理环境变量传递

环境

  • OpenClaw 版本:v22.22.0
  • Node 版本:v22.22.0
  • macOS 14.6 (arm64)

extent analysis

TL;DR

Modify the exec tool to automatically inject environment variables from skills.<name>.env into the subprocess environment for skill-related commands.

Guidance

  • Identify the exec tool's current implementation and determine how it handles environment variables for subprocesses.
  • Consider modifying the exec tool to parse the openclaw.json configuration file and inject the required environment variables for skill-related commands.
  • Alternatively, explore modifying the skill executor to handle environment variable passing uniformly.
  • Verify that the modified solution works by testing the skill script with the expected environment variables.

Example

// Example of how the exec tool could be modified to inject environment variables
const exec = require('child_process').exec;
const openclawConfig = require('./openclaw.json');

exec('node ~/.openclaw/skills/tavily-search/scripts/search.mjs "test"', {
  env: {
    ...process.env,
    ...openclawConfig.skills.tavily.env
  }
}, (error, stdout, stderr) => {
  // Handle the result
});

Notes

The proposed solution assumes that the exec tool is responsible for launching the subprocess and that modifying it to inject environment variables is feasible. Additionally, the example code snippet is a simplified illustration and may require adjustments to fit the actual implementation.

Recommendation

Apply a workaround by modifying the exec tool to inject environment variables, as this approach addresses the specific issue without requiring a version upgrade or significant changes to the existing codebase.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING