Skip to content

[Bug]: Log-level precedence should be Agent > CLI > Config (MCP logging/setLevel ignored when CLI/Config set) #3533

@anushakolan

Description

@anushakolan

Description

Today, the runtime log-level precedence is CLI > Config > Agent. When either --LogLevel is passed on the CLI or runtime.telemetry.log-level is set in config, MCP logging/setLevel requests are silently rejected and the agent has no way to change the level at runtime.

Per the team's discussion locked on 5/1 (Jerry, confirmed by Aniruddh), the intended precedence is Agent > CLI > Config:

  1. If nothing is set anywhere → defaults (Production = Error, Development = Debug; --mcp-stdio = None).
  2. Config sets the default level.
  3. CLI overrides Config.
  4. Agent (logging/setLevel) overrides CLI and Config.

Expected

  • With dab start --LogLevel Error running, an MCP logging/setLevel debug request takes effect and subsequent logs include Debug entries.
  • With runtime.telemetry.log-level: error in config, an MCP logging/setLevel debug request takes effect.
  • CLI continues to override Config when the agent doesn't speak up.

Actual

  • DynamicLogLevelProvider.UpdateFromMcp returns false when IsCliOverridden || IsConfigOverridden, so the level never changes.
  • Unit tests "CLI override blocks MCP change" and "Config override blocks MCP change" lock this behavior.

Repro

  1. dab start --LogLevel Error --mcp-stdio (or any host with --LogLevel).
  2. Send MCP request:
    {"jsonrpc":"2.0","method":"logging/setLevel","params":{"level":"debug"},"id":1}
  3. Trigger any operation that would emit Debug logs.
  4. Observe: no Debug entries appear; the agent's request was silently ignored.

Proposed fix

  1. Remove the CLI / Config early-rejects in DynamicLogLevelProvider.UpdateFromMcp.
  2. Add IsAgentOverridden and have UpdateFromRuntimeConfig skip when it's set (so hot-reload doesn't clobber the agent).
  3. Emit an Information log line when the agent successfully changes the level, so operators can see the override.
  4. Update existing tests to reflect Agent > CLI > Config; add a hot-reload-after-agent test and an agent-beats-CLI test.
  5. Manual: dab start --mcp-stdio --LogLevel Error, send logging/setLevel debug, verify logs flow at Debug.

Out of scope

  • CLI > Config rule (unchanged — CLI still beats Config when the agent doesn't speak up).
  • Default levels (Production = Error, Development = Debug, --mcp-stdio = None — all unchanged).
  • Agent "release" of override (no team ask yet — call as a follow-up if reviewers raise it).

Metadata

Metadata

Assignees

Type

Projects

Status

Review In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions