Skip to content

feat: add custom environment variables for conductor sessions#341

Merged
asheshgoplani merged 1 commit intoasheshgoplani:mainfrom
BestSithInEU:feat/conductor-custom-env
Mar 17, 2026
Merged

feat: add custom environment variables for conductor sessions#341
asheshgoplani merged 1 commit intoasheshgoplani:mainfrom
BestSithInEU:feat/conductor-custom-env

Conversation

@BestSithInEU
Copy link
Copy Markdown
Contributor

Summary

Adds -env KEY=VALUE (repeatable) and -env-file flags to conductor setup, enabling conductors to run with custom environment variables. This matches the existing env support already available for custom tools via [tools.X].env.

Closes #256

Changes

  • internal/session/conductor.go: Add Env map[string]string and EnvFile string fields to ConductorMeta, update SetupConductor() signature
  • internal/session/env.go: Add getConductorEnv() — detects conductor sessions by title prefix, loads meta.json, and builds export commands. Applied as step 6 in buildEnvSourceCommand() (highest priority, overrides tool env)
  • cmd/agent-deck/conductor_cmd.go: Add -env and -env-file flags with envVarFlags type for repeatable KEY=VALUE parsing, update help text
  • internal/session/conductor_test.go: Update existing test calls + add TestSetupConductor_WithEnvVars and TestSetupConductor_WithoutEnvVars

Usage

# Setup conductor with Z.ai GLM backend (the original issue's use case)
agent-deck conductor setup mybot \
  -env ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic \
  -env ANTHROPIC_AUTH_TOKEN=<token> \
  -env ANTHROPIC_DEFAULT_SONNET_MODEL=glm-4.7 \
  -env ANTHROPIC_DEFAULT_OPUS_MODEL=glm-5

# Or with an env file
agent-deck conductor setup mybot -env-file ~/.conductor.env

Env vars are stored in meta.json and exported before the conductor command launches via the existing buildEnvSourceCommand() pipeline.

Test plan

  • TestSetupConductor_WithEnvVars — verifies env vars and env_file are stored in meta.json
  • TestSetupConductor_WithoutEnvVars — verifies nil env when none provided
  • All 15 existing conductor tests pass (no regressions)
  • Manual test: conductor setup with -env flags correctly writes to meta.json
  • End-to-end test with actual alternative backend not performed (requires third-party API key). The env sourcing path (buildEnvSourceCommandgetConductorEnv) follows the same proven pattern used by custom tools.

Note on pre-existing test failures

TestLifecycle_StoppedRestartedRunningError and TestStatusCycle_ShellSessionWithCommand fail on main as well — they are flaky tmux timing tests unrelated to this change.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for conductor-specific environment variables by allowing conductor setup to persist env / env_file into meta.json and sourcing them when launching conductor sessions.

Changes:

  • Extends ConductorMeta and SetupConductor() to persist inline env vars and an env file path.
  • Adds conductor-specific env sourcing to the existing buildEnvSourceCommand() pipeline with highest precedence.
  • Introduces -env (repeatable) and -env-file flags to agent-deck conductor setup, plus new/updated unit tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
internal/session/conductor.go Adds Env / EnvFile to conductor metadata and persists them during setup.
internal/session/env.go Adds getConductorEnv() and sources conductor env last (highest priority) in env pipeline.
cmd/agent-deck/conductor_cmd.go Adds CLI flags and parsing for repeatable -env KEY=VALUE and -env-file.
internal/session/conductor_test.go Updates existing SetupConductor call sites and adds env-focused setup tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@BestSithInEU BestSithInEU force-pushed the feat/conductor-custom-env branch 2 times, most recently from 6c17423 to 12dab6d Compare March 16, 2026 16:52
Conductors can now be configured with custom environment variables via
-env KEY=VALUE (repeatable) and -env-file flags on conductor setup.

This enables running conductors with alternative AI backends (e.g. Z.ai
GLM models) by setting ANTHROPIC_BASE_URL and related env vars, matching
the existing env support already available for custom tools.

- Add Env and EnvFile fields to ConductorMeta (stored in meta.json)
- Add getConductorEnv() to env.go that loads conductor env at session start
- Add -env and -env-file flags to conductor setup CLI
- Add tests for env var storage and retrieval

Closes asheshgoplani#256
@BestSithInEU BestSithInEU force-pushed the feat/conductor-custom-env branch from 12dab6d to def498d Compare March 16, 2026 17:18
@asheshgoplani asheshgoplani merged commit 45313bf into asheshgoplani:main Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to use custom env variables for conductors

3 participants