Let capture_env patterns be persisted in config.yaml - #71
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
wb.*attributes / session tags were showing up for agents run one way but not another. Root cause:Config.load()readcapture_env_patternsonly fromTHIRDEYE_CAPTURE_ENVinos.environ— so capture depended entirely on the launching shell.An agent run straight from an interactive terminal (where
.zshrcexported 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 acapture_envkey in~/.thirdeye/config.yaml(accepts a comma string'WB_*, BUILD_LABEL'or a YAML list) whenTHIRDEYE_CAPTURE_ENVis unset. The env var still wins when set, so one-off overrides keep working.Config.write_capture_env_patterns()— persist helper, mirrorswrite_logfire_settings(preserves other keys; empty clears).thirdeye capture-envcommand group:set 'WB_*',show(patterns + source),clear.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