mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-19 20:34:45 +08:00
feat(acp): add env field to ACPAgentConfig for subprocess env injection (#1447)
Allow per-agent environment variables to be declared in config.yaml under acp_agents.<name>.env. Values prefixed with $ are resolved from the host environment at invocation time, consistent with other config fields. Passes None to spawn_agent_process when env is empty so the subprocess inherits the parent environment unchanged. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -64,10 +64,36 @@ def test_load_acp_config_none_clears_agents():
|
||||
def test_acp_agent_config_defaults():
|
||||
cfg = ACPAgentConfig(command="my-agent", description="My agent")
|
||||
assert cfg.args == []
|
||||
assert cfg.env == {}
|
||||
assert cfg.model is None
|
||||
assert cfg.auto_approve_permissions is False
|
||||
|
||||
|
||||
def test_acp_agent_config_env_literal():
|
||||
cfg = ACPAgentConfig(command="my-agent", description="desc", env={"OPENAI_API_KEY": "sk-test"})
|
||||
assert cfg.env == {"OPENAI_API_KEY": "sk-test"}
|
||||
|
||||
|
||||
def test_acp_agent_config_env_default_is_empty():
|
||||
cfg = ACPAgentConfig(command="my-agent", description="desc")
|
||||
assert cfg.env == {}
|
||||
|
||||
|
||||
def test_load_acp_config_preserves_env():
|
||||
load_acp_config_from_dict(
|
||||
{
|
||||
"codex": {
|
||||
"command": "codex-acp",
|
||||
"args": [],
|
||||
"description": "Codex CLI",
|
||||
"env": {"OPENAI_API_KEY": "$OPENAI_API_KEY", "FOO": "bar"},
|
||||
}
|
||||
}
|
||||
)
|
||||
cfg = get_acp_agents()["codex"]
|
||||
assert cfg.env == {"OPENAI_API_KEY": "$OPENAI_API_KEY", "FOO": "bar"}
|
||||
|
||||
|
||||
def test_acp_agent_config_with_model():
|
||||
cfg = ACPAgentConfig(command="my-agent", description="desc", model="claude-opus-4")
|
||||
assert cfg.model == "claude-opus-4"
|
||||
|
||||
Reference in New Issue
Block a user