Skip to content

Let capture_env patterns be persisted in config.yaml - #71

Merged
duncankmckinnon merged 1 commit into
mainfrom
feat/capture-env-config-fallback
Sep 11, 2026
Merged

Let capture_env patterns be persisted in config.yaml#71
duncankmckinnon merged 1 commit into
mainfrom
feat/capture-env-config-fallback

Conversation

@duncankmckinnon

Copy link
Copy Markdown
Owner

Why

wb.* attributes / session tags were showing up for agents run one way but not another. Root cause: Config.load() read capture_env_patterns only from THIRDEYE_CAPTURE_ENV in os.environ — so capture depended entirely on the launching shell.

An agent run straight from an interactive terminal (where .zshrc exported the var) works. An agent dispatched from a context that never sources the user's rc — workbench's tmux wrapper forwarding its own env, a GUI-launched process, cron — sees no pattern and captures nothing. Same thirdeye, same platform, different launch context → different result.

Change

  • Config.load() falls back to a capture_env key in ~/.thirdeye/config.yaml (accepts a comma string 'WB_*, BUILD_LABEL' or a YAML list) when THIRDEYE_CAPTURE_ENV is unset. The env var still wins when set, so one-off overrides keep working.
  • Config.write_capture_env_patterns() — persist helper, mirrors write_logfire_settings (preserves other keys; empty clears).
  • thirdeye capture-env command group: set 'WB_*', show (patterns + source), clear.
  • README: documents the persisted path.

Set once, works for every platform and every launch context.

Tests

test_config.py — env-over-file precedence, string + list forms, write/reload/clear, key preservation. test_capture_env_command.py — the CLI group. Full suite: 2720 passed. ruff clean.

Part of the workbench#68 / thirdeye#68 / #69 / #70 chain.

🤖 Generated with Claude Code

Config.load() read capture_env_patterns only from THIRDEYE_CAPTURE_ENV
in os.environ. That makes capture depend on the launching shell: an
agent dispatched from a context that never sources the user's rc
(workbench's tmux wrapper forwards its own env, cron, a GUI) sees no
pattern and captures nothing -- no wb.* attributes, no tags -- while an
agent run straight from an interactive terminal works.

Fall back to a `capture_env` key in ~/.thirdeye/config.yaml (string or
list) when the env var is unset; the env var still overrides for one-off
runs. Add `Config.write_capture_env_patterns()` and a `thirdeye
capture-env` command group (show / set / clear) to manage it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@duncankmckinnon
duncankmckinnon merged commit 792ee60 into main Sep 11, 2026
7 checks passed
@duncankmckinnon
duncankmckinnon deleted the feat/capture-env-config-fallback branch September 11, 2026 00:06
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.

1 participant