From d26bfc2a3fce8e5d24ee6bfe6b5ea8bc3eaccfa1 Mon Sep 17 00:00:00 2001 From: sim Date: Sat, 15 Aug 2026 03:19:18 -0400 Subject: [PATCH] fix(#3534): resolve-execution reports resolved and effective effort --- .changeset/bold-badgers-climb.md | 5 +++++ docs/CONFIGURATION.md | 8 ++++++++ src/commands.cts | 34 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 .changeset/bold-badgers-climb.md diff --git a/.changeset/bold-badgers-climb.md b/.changeset/bold-badgers-climb.md new file mode 100644 index 000000000..7ebba6cb1 --- /dev/null +++ b/.changeset/bold-badgers-climb.md @@ -0,0 +1,5 @@ +--- +type: Added +pr: 0 +--- +**`resolve-execution` now tells the truth about what the agent will run at** — the query reported only the config-cascade effort, which is not what an installed agent uses when its `effort:` frontmatter was hand-stripped or drifted. `--json` adds `effort_effective` (read from the installed agent frontmatter for the claude runtime; `"inherit"` when the key is absent) and `effort_effective_source` (`frontmatter` | `frontmatter-absent` | `resolved`). All existing fields, including `--pick effort`, are unchanged. (#3534) diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index a3bc1cd34..cbaf11ac1 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -1416,6 +1416,14 @@ The model-catalog's `reasoning_effort` per-tier hint is a legacy field kept for Valid effort values: `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. +`query resolve-execution --json` reports two effort views ([#3534](https://github.com/open-gsd/gsd-core/issues/3534)): +`effort` is the **resolved** config-cascade value; `effort_effective` is what the installed +agent will actually run at — read from the installed agent's `effort:` frontmatter for the +claude runtime (`effort_effective_source: "frontmatter"`), reported as `"inherit"` when the +key is absent (`"frontmatter-absent"` — the agent follows the session effort), and equal to +the resolved value with source `"resolved"` when there is no install-time channel or no +agent file to read. `--pick effort` still returns the resolved value. + #### Where effort actually reaches — added in v1.8.0 Effort resolved from the cascade above reaches a runtime through one of two channels. diff --git a/src/commands.cts b/src/commands.cts index a3fee9521..cc54fa41c 100644 --- a/src/commands.cts +++ b/src/commands.cts @@ -620,6 +620,38 @@ function cmdResolveExecution(cwd: string, agentType: string | undefined, raw: bo const fastModeSupported = RUNTIMES_WITH_FAST_MODE.has(runtime); + // #3534 (10a): the effective effort — what the installed agent will actually + // run at. `effort` above is the config cascade; for the claude runtime the + // per-agent frontmatter key is the source of truth (Claude Code's Agent tool + // has no per-spawn effort parameter), so the query reads the installed file. + // An ABSENT key is a real state — the agent follows the session effort + // ('inherit'), not drift. No file / no frontmatter / any read failure means + // no evidence: the resolved value is reported, flagged 'resolved' so a + // consumer can tell evidence from echo. Additive only — every existing key + // is unchanged. + let effortEffectiveSource: 'frontmatter' | 'frontmatter-absent' | 'resolved' = 'resolved'; + let effortEffective: string = effort; + if (runtime === 'claude') { + try { + // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/unbound-method + const { getGlobalConfigDir } = require('./runtime-homes.cjs') as { getGlobalConfigDir(runtime: string, explicitDir?: string | null): string }; + const agentPath = path.join(getGlobalConfigDir(runtime), 'agents', `${agentType}.md`); + const agentContent = fs.readFileSync(agentPath, 'utf8'); + // eslint-disable-next-line local/no-unbounded-quantifier -- same lazy `*?` bounded by the `^---$/m` closing anchor as the sibling frontmatter regexes in this file + const fmMatchEff = /^---\r?\n([\s\S]*?)^---\r?$/m.exec(agentContent); + if (fmMatchEff) { + const effortLine = /^effort:[ \t]*(.+?)[ \t]*$/m.exec(fmMatchEff[1]); + if (effortLine) { + effortEffective = effortLine[1]; + effortEffectiveSource = 'frontmatter'; + } else { + effortEffective = 'inherit'; + effortEffectiveSource = 'frontmatter-absent'; + } + } + } catch { /* no frontmatter evidence — stay on the resolved value */ } + } + // Own-property guard: agentType is an unvalidated CLI positional, so a // prototype-chain value ("toString", "constructor") would otherwise return // an inherited truthy member from this plain object and misreport a @@ -633,6 +665,8 @@ function cmdResolveExecution(cwd: string, agentType: string | undefined, raw: bo effort_rendered: rendered.value, effort_param: rendered.param, effort_propagation: rendered.channel, + effort_effective: effortEffective, + effort_effective_source: effortEffectiveSource, fast_mode: fastMode, fast_mode_supported: fastModeSupported, };