Repository navigation
Honor AGENT_TRACE_DIR in CLI read commands - #296
Merged
Siddhant-K-code merged 1 commit intoOct 25, 2026
Merged
Conversation
Hooks and auto-instrumentation write to $AGENT_TRACE_DIR, but the global --trace-dir flag defaulted to the literal ".agent-traces", so list, replay, health, stats, mcp, dashboard, watch and other commands could not see sessions recorded there. Add store.default_trace_dir(), read at call time, and use it as the --trace-dir default and in the hook and integration writers. Precedence: explicit --trace-dir, then a non-empty $AGENT_TRACE_DIR, then .agent-traces. Relative values resolve against the working directory. An empty AGENT_TRACE_DIR is now treated as unset by hooks and integrations too. Previously it resolved to the working directory, so hook files landed in the project root without a .gitignore. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Siddhant-K-code
deleted the
siddhant-k-code-fix-cli-honors-agent-trace-dir
branch
October 25, 2026 10:36
Siddhant-K-code
added a commit
that referenced
this pull request
Oct 25, 2026
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.
Problem
Hooks and auto-instrumentation write sessions to
$AGENT_TRACE_DIR, but the global--trace-dirflag defaulted to the literal.agent-traces. WithAGENT_TRACE_DIRset,list,replay,health,statsand the other read commands looked in./.agent-tracesand missed every session the hooks had recorded.Change
store.default_trace_dir()is a single resolver, read on each call rather than at import time. It is now used by:--trace-dirdefault incli.py(computed inbuild_parser(), so each invocation and each test that patchesos.environsees the current value)hooks._get_store_dir()integrations/_base._get_store()Precedence:
--trace-dir DIR.$AGENT_TRACE_DIR, when set and non-empty..agent-traces. Hooks keep their existing fallback to<payload cwd>/.agent-tracesbefore this.Relative values are passed through unchanged, so writers and readers resolve them against the working directory.
Every command that builds
TraceStore(args.trace_dir)picks up the new default, includinglist,replay,inspect,export,stats,health,mcp,dashboard,watch,retention,importandconfig-watch.Behavior change: empty
AGENT_TRACE_DIRHooks checked
"AGENT_TRACE_DIR" in os.environand integrations usedos.environ.get(..., default). Both passed an empty string through as the store path, which resolves to the working directory. Hook files then landed in the project root, and.gitignoreprotection did not apply because the store refuses to ignore the cwd. An empty value is now treated as unset everywhere, so the CLI, hooks and integrations agree.Left alone on purpose
_command_indexargv pre-scan: it only skips--trace-dirtokens and resolves no directory.server --storage: a separate collector with its ownAGENT_STRACE_STORAGEvariable.rbac,applyandconfig-diff --dir: admin config stores that hooks never write, and they never read the global--trace-dir.decorator.start_session(trace_dir=...), a possible follow-upjsonl_import.import_jsonlworkspace.pyhelpersTraceStoreconstructorbaseline.json,datasets/default.jsonl,eval-summary.md, the watchalerts.logand the config-watch snapshot.config-watchworkspace root: it is derived from the trace dir's parent. That is existing behavior and a possible follow-up.agentTrace.traceDirsetting.action.yml: it passes--trace-direxplicitly.Docs
docs/commands.md: new "Global options" section with the precedence rules.docs/setup.md: short note onAGENT_TRACE_DIR.--trace-dirhelp text now describes the env fallback.Tests
tests/test_trace_dir_env.pyclearsAGENT_TRACE_DIRand related env insetUpand runs inside a temp cwd. It covers:list,replay,inspect,health,stats,mcp,dashboardandwatchdefaulting to the env dirlist,healthandreplayreading it throughmain()--trace-diroverriding the env.agent-tracesFull suite: 2404 tests pass (2 skipped) both with
AGENT_TRACE_DIRunset and with it set to a temp directory.No version bump.