Skip to content

Add Dashboard run history access for agents - #18934

Closed
James Newton-King (JamesNK) wants to merge 4 commits into
mainfrom
jamesnk/dashboard-run-history-agent-access
Closed

James Newton-King (JamesNK) wants to merge 4 commits into
mainfrom
jamesnk/dashboard-run-history-agent-access

Conversation

@JamesNK

Copy link
Copy Markdown
Member

Description

Agents need a stable way to diagnose an Aspire application after an AppHost run has ended and to compare telemetry across reproductions. This change makes persisted Dashboard runs addressable from the CLI, the CLI MCP server, and the Dashboard telemetry HTTP API.

Users can assign a validated, unique run ID with aspire start --run-id or aspire run --run-id. The effective ID is included in launch output. Console logs, structured logs, traces, and spans can then be queried from an immutable retained run by passing --run-id; the four corresponding MCP tools accept the same optional runId. Historical streaming is rejected, and missing runs return explicit errors rather than falling back to current data.

The Dashboard performs the authoritative duplicate check using an adjacent run lock, exposes request-scoped historical snapshots, and persists console-log snapshots for historical access. The specs include an end-to-end agent workflow for before/after diagnosis and trace-to-log correlation.

This PR is stacked on and depends on #18925.

User-facing usage

Create named runs for a before/after investigation:

aspire start --run-id incident-42-before --format json
aspire start --run-id incident-42-after --format json

Compare retained telemetry after either AppHost has stopped:

aspire logs apiservice --run-id incident-42-before --format json
aspire otel logs apiservice --run-id incident-42-before --severity Error --format json
aspire otel traces apiservice --run-id incident-42-before --has-error --format json
aspire otel spans --run-id incident-42-before --trace-id <trace-id> --format json

The CLI MCP server exposes runId on:

  • list_console_logs
  • list_structured_logs
  • list_traces
  • list_trace_structured_logs

Screenshots / Recordings

This PR includes CLI output changes. Please add screenshots or screen recordings so reviewers can evaluate the output without running locally.

  • For before/after comparisons, place them side-by-side or label them clearly.
  • For interactive changes, prefer a short screen recording (GIF or video).
  • If you cannot capture visuals now, note what scenario to test and mark this section as TODO.

TODO: Capture aspire start --run-id incident-42 --format json and a historical telemetry query.

Security considerations

The user-provided run ID becomes part of a path under the Dashboard data directory. Run IDs are restricted to portable ASCII slugs, reject traversal, separators, Unicode, edge punctuation, and Windows device names, and are checked again by the Dashboard before creating storage. Historical telemetry remains protected by the Dashboard API's existing authentication mode and may contain sensitive diagnostic data. Security review has not yet been completed.

Validation

  • Aspire.Cli.Tests: 243 affected tests passed.
  • Aspire.Dashboard.Tests: 119 affected tests passed.
  • Aspire.Hosting.Tests: 88 affected tests passed.
  • build.cmd /p:SkipNativeBuild=true succeeded.
  • Generated localization entries and documentation links were validated.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Copilot AI balanced review requested due to automatic review settings July 30, 2026 04:28
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18934

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18934"

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds stable Dashboard run IDs and historical telemetry access across Hosting, Dashboard HTTP APIs, CLI commands, and MCP tools.

Changes:

  • Adds validated named run creation and launch output.
  • Adds request-scoped historical telemetry and console-log APIs.
  • Adds CLI/MCP query options, tests, localization, and specifications.

Reviewed changes

Copilot reviewed 81 out of 83 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.Tests/Dashboard/DashboardEventHandlersTests.cs Tests duplicate run IDs.
tests/Aspire.Hosting.Tests/Backchannel/AuxiliaryBackchannelRpcTargetTests.cs Tests backchannel run IDs.
tests/Aspire.Dashboard.Tests/Model/DashboardDataSourceTests.cs Tests validation, storage, and leases.
tests/Aspire.Dashboard.Tests/Integration/TelemetryApiTests.cs Tests historical API selection.
tests/Aspire.Dashboard.Tests/Integration/StartupTests.cs Tests run-ID startup logging.
tests/Aspire.Cli.Tests/Mcp/ListTraceStructuredLogsToolTests.cs Tests MCP run-ID forwarding.
tests/Aspire.Cli.Tests/Mcp/ListTracesToolTests.cs Tests trace run-ID forwarding.
tests/Aspire.Cli.Tests/Mcp/ListStructuredLogsToolTests.cs Tests log run-ID forwarding.
tests/Aspire.Cli.Tests/Mcp/ListConsoleLogsToolTests.cs Tests historical console logs.
tests/Aspire.Cli.Tests/Commands/StartCommandTests.cs Tests start validation.
tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs Tests launch behavior and output.
tests/Aspire.Cli.Tests/Commands/LogsCommandTests.cs Tests historical log queries.
tests/Aspire.Cli.Tests/Commands/AgentMcpCommandTests.cs Tests dashboard-only MCP tools.
src/Shared/Otlp/Serialization/TelemetryApiResponse.cs Adds console-log DTOs.
src/Shared/Otlp/Serialization/OtlpJsonSerializerContext.cs Registers console-log serialization.
src/Shared/DashboardUrls.cs Builds run-scoped API URLs.
src/Shared/DashboardRunStorage.cs Shares run-directory naming.
src/Shared/DashboardConfigNames.cs Adds run configuration and validation.
src/Aspire.Hosting/DistributedApplicationBuilder.cs Registers run identity.
src/Aspire.Hosting/Dashboard/DashboardRunIdentity.cs Stores effective run identity.
src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs Resolves and forwards run IDs.
src/Aspire.Hosting/Backchannel/DashboardUrlsHelper.cs Reports run IDs over backchannel.
src/Aspire.Hosting/Backchannel/BackchannelDataTypes.cs Extends backchannel contracts.
src/Aspire.Hosting/Backchannel/AuxiliaryBackchannelRpcTarget.cs Returns run IDs through RPC.
src/Aspire.Hosting/Aspire.Hosting.csproj Links shared storage helpers.
src/Aspire.Dashboard/ServiceClient/DashboardRunStore.cs Supports named runs and metadata ordering.
src/Aspire.Dashboard/ServiceClient/DashboardDataSource.cs Adds strict run selection.
src/Aspire.Dashboard/DashboardWebApplication.cs Scopes telemetry API services.
src/Aspire.Dashboard/DashboardEndpointsBuilder.cs Adds historical API routing.
src/Aspire.Dashboard/Configuration/ValidateDashboardOptions.cs Validates configured IDs.
src/Aspire.Dashboard/Configuration/PostConfigureDashboardOptions.cs Binds run configuration.
src/Aspire.Dashboard/Configuration/DashboardOptions.cs Stores configured run ID.
src/Aspire.Dashboard/Aspire.Dashboard.csproj Links shared storage helpers.
src/Aspire.Dashboard/Api/TelemetryApiService.cs Queries selected-run telemetry.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.zh-Hant.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.zh-Hans.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.tr.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ru.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.pt-BR.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.pl.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ko.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ja.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.it.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.fr.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.es.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.de.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.cs.xlf Updates localization resources.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hant.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hans.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.tr.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.ru.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.pt-BR.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.pl.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.ko.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.ja.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.it.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.fr.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.es.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.de.xlf Updates launch localization.
src/Aspire.Cli/Resources/xlf/RunCommandStrings.cs.xlf Updates launch localization.
src/Aspire.Cli/Resources/TelemetryCommandStrings.resx Adds telemetry messages.
src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs Exposes telemetry resources.
src/Aspire.Cli/Resources/RunCommandStrings.resx Adds launch messages.
src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs Exposes launch resources.
src/Aspire.Cli/Mcp/Tools/McpToolHelpers.cs Parses optional MCP arguments.
src/Aspire.Cli/Mcp/Tools/ListTraceStructuredLogsTool.cs Adds historical trace-log access.
src/Aspire.Cli/Mcp/Tools/ListTracesTool.cs Adds historical trace access.
src/Aspire.Cli/Mcp/Tools/ListStructuredLogsTool.cs Adds historical structured logs.
src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs Adds Dashboard console-log access.
src/Aspire.Cli/Commands/TelemetryTracesCommand.cs Adds trace run selection.
src/Aspire.Cli/Commands/TelemetrySpansCommand.cs Adds span run selection.
src/Aspire.Cli/Commands/TelemetryLogsCommand.cs Adds structured-log run selection.
src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs Adds shared run-query behavior.
src/Aspire.Cli/Commands/StartCommand.cs Forwards named run IDs.
src/Aspire.Cli/Commands/RunCommand.cs Creates and displays named runs.
src/Aspire.Cli/Commands/LogsCommand.cs Queries historical console logs.
src/Aspire.Cli/Commands/AppHostLauncher.cs Propagates run IDs for detached launches.
src/Aspire.Cli/Commands/AgentMcpCommand.cs Enables console logs in dashboard-only MCP.
src/Aspire.Cli/Backchannel/AppHostAuxiliaryBackchannel.cs Carries run IDs through compatibility fallback.
docs/specs/dashboard-persistence.md Documents named-run persistence.
docs/specs/dashboard-http-api.md Documents historical HTTP APIs.
docs/specs/cli-output-formats.md Documents CLI run output and queries.
docs/specs/agent-run-history-diagnostics.md Adds the agent diagnostic workflow.
Files not reviewed (2)
  • src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs: Generated file
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file

public static async Task<ResourceInfoJson[]> GetAllResourcesAsync(HttpClient client, string baseUrl, CancellationToken cancellationToken, string? runId = null)
{
var url = DashboardUrls.TelemetryResourcesApiUrl(baseUrl);
var url = DashboardUrls.TelemetryResourcesApiUrl(baseUrl, runId);
Comment on lines 418 to +423
if (dashboardUrls.DashboardHealthy is false)
{
if (runId is not null)
{
await CancelAppHostStartupAsync(runCts, runTask, cancellationToken).ConfigureAwait(false);
return CommandResult.Failure(CliExitCodes.FailedToDotnetRunAppHost, RunCommandStrings.DashboardFailedToStartWithRunId);
Comment on lines +97 to +102
foreach (var character in value)
{
if (!IsAsciiLetterOrDigit(character) && character is not '-' and not '_' and not '.')
{
errorMessage = "it may contain only ASCII letters, numbers, periods, underscores, and hyphens";
return false;
Comment on lines +218 to +222
_innerBuilder.Services.AddSingleton(new DashboardRunIdentity
{
RunId = configuredDashboardRunId,
IsUserSpecified = configuredDashboardRunId is not null
});
Comment on lines +414 to +418
var totalCount = logs.Count;
if (limit is > 0 && logs.Count > limit.Value)
{
logs = logs.Skip(logs.Count - limit.Value).ToList();
}
Comment on lines +127 to +132
else
{
if (_dashboardInfoProvider is null || _httpClientFactory is null)
{
throw new McpProtocolException("Historical console logs require a Dashboard connection.", McpErrorCode.InternalError);
}
Comment on lines +355 to +358
if (runId is not null && ex.StatusCode == HttpStatusCode.NotFound)
{
return new TelemetryErrorInfo(FormatHistoricalRunNotFound(runId));
}
Comment on lines +215 to +218
if (runId is not null && ex is HttpRequestException { StatusCode: System.Net.HttpStatusCode.NotFound })
{
throw new McpProtocolException(TelemetryCommandHelpers.FormatHistoricalRunNotFound(runId), McpErrorCode.InternalError);
}
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI review requested due to automatic review settings July 31, 2026 07:31
@JamesNK
James Newton-King (JamesNK) force-pushed the jamesnk/dashboard-run-history-agent-access branch from 48c7529 to e78b6b0 Compare July 31, 2026 07:31
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 81 out of 83 changed files in this pull request and generated no new comments.

Files not reviewed (2)
  • src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs: Generated file
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file
Suppressed comments (9)

src/Aspire.Hosting/DistributedApplicationBuilder.cs:233

  • An empty configured value skips validation but is still marked user-specified and retained as RunId = "". Hosting then either treats the runs directory itself as a duplicate or reports an empty run ID while the Dashboard's fallbackOnEmpty logic creates a different timestamp ID. Normalize empty values to an unspecified run.
    src/Aspire.Dashboard/Api/TelemetryApiService.cs:417
  • logs is populated one resource at a time, so it is grouped by resource rather than globally ordered. Applying Skip here means an unfiltered multi-resource request returns lines from whichever resources were enumerated last, not the newest matching lines promised by limit. Establish a global chronological/insertion order before taking the tail.
    src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:104
  • The ExcludeFromMcp check is confined to this live branch. Supplying runId takes the Dashboard branch and returns console logs for an excluded resource, violating the invariant that excluded resources are omitted from all MCP tool results. Apply exclusion handling to historical requests as well, using the selected run's resource metadata where necessary.
            if (runId is null && _auxiliaryBackchannelMonitor is not null)

src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs:358

  • A 404 does not establish that the run is missing: /console-logs also returns 404 when the run exists but the requested resource does not. Because LogsCommand routes that response through this method with a non-null runId, aspire logs typo --run-id valid-run incorrectly reports that valid-run was not found. Preserve or inspect the problem details, or validate the run/resource separately.
        if (runId is not null && ex.StatusCode == HttpStatusCode.NotFound)
        {
            return new TelemetryErrorInfo(FormatHistoricalRunNotFound(runId));
        }

src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:217

  • This similarly treats every historical console-log 404 as a missing run, but the endpoint returns the same status for an unknown resource in a valid run. MCP callers therefore receive the wrong diagnosis. Distinguish the Dashboard Run not found problem from Resource not found before formatting the exception.
            if (runId is not null && ex is HttpRequestException { StatusCode: System.Net.HttpStatusCode.NotFound })
            {
                throw new McpProtocolException(TelemetryCommandHelpers.FormatHistoricalRunNotFound(runId), McpErrorCode.InternalError);

src/Aspire.Dashboard/DashboardEndpointsBuilder.cs:317

  • This allows follow=true when runId names the current run because that selection is not read-only. The CLI rejects every --follow --run-id combination, and the new HTTP contract says every request combining these parameters returns 400. Check whether an explicit run ID was supplied rather than whether it currently resolves as historical.
    src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:141
  • resourceName is required for this tool, and the live MCP path can query hidden resources (MCP discovery also requests hidden snapshots). Passing includeHidden: false makes the historical path return “resource not found” for the same hidden resource. Preserve the live behavior for explicit resource queries.
                    includeHidden: false,

src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:21

  • The summary is now inaccurate: this class forwards retained-run requests through the Dashboard API, and dashboard-only mode also uses that path without a runId. Update it to describe the live-backchannel and Dashboard-snapshot behaviors.
internal sealed class ListConsoleLogsTool : CliMcpTool

tests/Aspire.Dashboard.Tests/Integration/TelemetryApiTests.cs:290

  • This exercises only an empty historical response. It would still pass if console-log run selection accidentally returned the current repository or if persisted rows were never exposed. Seed distinct console lines in the historical and current runs, then assert that the runId request returns only the historical content.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI review requested due to automatic review settings August 3, 2026 15:13
@JamesNK
James Newton-King (JamesNK) force-pushed the jamesnk/dashboard-run-history-agent-access branch from e78b6b0 to 40e03c0 Compare August 3, 2026 15:13
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 81 out of 83 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs: Generated file
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file
Suppressed comments (9)

src/Aspire.Hosting/DistributedApplicationBuilder.cs:233

  • An empty ASPIRE_DASHBOARD_RUN_ID is skipped by validation but is still stored as a user-specified, non-null ID. ResolveRunIdentity() then preserves the empty string while the Dashboard treats it as absent, so launch output/backchannel metadata can report "" instead of the Dashboard's generated ID (and non-Run persistence can fail unexpectedly). Normalize empty values to null here.
    src/Aspire.Dashboard/Api/TelemetryApiService.cs:417
  • logs is grouped by resource because each resource is enumerated separately, so taking the final limit entries does not return the newest lines across resources. For an unfiltered console-logs?limit=N request, older lines from the last resource can displace newer lines from earlier resources, contradicting the endpoint's “newest matching lines” contract. Apply the limit against a global persisted ordering (or merge the per-resource streams by that ordering).
    src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:136
  • The historical/HTTP branch bypasses the ExcludeFromMcp check performed by the live branch, so supplying runId can expose console logs for a resource that the current AppHost explicitly removed from MCP. Preserve the exclusion check before issuing the historical request, matching the structured-log tools and McpToolHelpers' requirement that excluded resources be omitted from all MCP results.
                var (apiToken, apiBaseUrl, _) = await _dashboardInfoProvider.GetDashboardInfoAsync(cancellationToken).ConfigureAwait(false);
                using var client = TelemetryCommandHelpers.CreateApiClient(_httpClientFactory, apiToken);
                var url = DashboardUrls.TelemetryConsoleLogsApiUrl(

src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:217

  • This treats every historical console-log 404 as a missing run, but /console-logs also returns 404 when resourceName is unknown. With a valid run and a mistyped resource, the MCP tool returns the wrong diagnostic. Inspect the ProblemDetails response (or otherwise distinguish resource-not-found) before emitting HistoricalRunNotFound.
            if (runId is not null && ex is HttpRequestException { StatusCode: System.Net.HttpStatusCode.NotFound })
            {
                throw new McpProtocolException(TelemetryCommandHelpers.FormatHistoricalRunNotFound(runId), McpErrorCode.InternalError);

src/Aspire.Cli/Commands/LogsCommand.cs:388

  • The console-log endpoint returns 404 for both an unknown run and an unknown resource, but passing runId to this formatter classifies every 404 as “run not found.” A typo in aspire logs <resource> --run-id <valid-run> therefore reports that the valid run is missing. Preserve the endpoint's ProblemDetails distinction (or otherwise distinguish the resource 404) before formatting the error.
                dashboardOnly: false,
                _httpClientFactory,
                _logger,
                cancellationToken,
                runId).ConfigureAwait(false);

src/Aspire.Hosting/Backchannel/DashboardUrlsHelper.cs:163

  • DashboardRunIdentity.RunId is allocated before the Dashboard creates or opens the run. Returning it from an unhealthy connection causes aspire run/start to print a “Dashboard run ID” (and emit runId in JSON) even when the Dashboard never persisted that run. Unhealthy connection info should not advertise the proposed ID as an available persisted run.
    docs/specs/dashboard-http-api.md:129
  • This states that any request combining follow=true and runId returns 400, but ValidateRunSelection only rejects when the selected run is historical; passing the current run's ID streams successfully. Document the actual historical-only restriction (or change the endpoint contract) so direct HTTP clients are not given a false guarantee.
Streaming is available only for the current run. Requests that combine `follow=true` with `runId` return `400 Bad Request`.

docs/specs/agent-run-history-diagnostics.md:233

  • The implementation permits follow=true when runId names the current run and rejects only historical selections, so this unconditional statement is inaccurate. Align this direct-HTTP contract with ValidateRunSelection.
- `follow=true` with `runId` returns `400 Bad Request`; and

src/Aspire.Cli/Commands/StartCommand.cs:97

  • This user-visible option relies on several process boundaries—start forwarding to detached run, environment propagation into the AppHost, Dashboard persistence/backchannel output, shutdown, and a later historical query—but the added tests exercise those pieces only with mocks. Add a CLI E2E scenario that starts an AppHost with --run-id, captures the emitted ID, stops it, and queries retained logs/telemetry; otherwise argument or protocol integration regressions can ship while all focused tests pass.
            if (runId is not null)
            {
                debugSessionArgs.Add(AppHostLauncher.s_runIdOption.Name);
                debugSessionArgs.Add(runId);
            }

{
await foreach (var batch in _dataSource.ResourceRepository.GetConsoleLogs(resource.Name, cancellationToken).ConfigureAwait(false))
{
logs.AddRange(batch
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI review requested due to automatic review settings August 3, 2026 23:58
@JamesNK
James Newton-King (JamesNK) force-pushed the jamesnk/dashboard-run-history-agent-access branch from 40e03c0 to c42c0f5 Compare August 3, 2026 23:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 81 out of 83 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs: Generated file
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file
Suppressed comments (8)

src/Aspire.Hosting/DistributedApplicationBuilder.cs:228

  • An explicitly configured empty run ID bypasses both validation checks, but is stored as user-specified. ResolveRunIdentity then does not generate an ID and checks the existing runs directory as the run directory, producing a misleading duplicate-ID failure. Treat every non-null configured value as input to validate so empty values fail with the intended validation error.
    src/Aspire.Dashboard/Api/TelemetryApiService.cs:417
  • The list is built resource-by-resource, so taking the final limit entries does not select the globally newest console lines. For aspire logs --run-id ... --tail N without a resource filter, results depend on resource enumeration order and can omit newer lines from earlier resources. Merge/order lines globally (for example by the persisted console-log sequence/timestamp) before applying the limit.
    src/Aspire.Dashboard/Api/TelemetryApiService.cs:397
  • limit is applied only after every selected resource has loaded all console rows. SqliteResourceRepository.GetConsoleLogs performs an unbounded SELECT followed by ToArray, so even a tail request for 100 lines materializes the entire retained run and can consume excessive memory. Push filtering and limiting into a repository-level SQLite query.
    src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs:358
  • A 404 does not uniquely mean the run is missing: the telemetry API also returns 404 for an unknown resource and for a missing trace. With a valid runId, those failures are now reported as “Dashboard run ... was not found,” hiding the actual error. Classify the RFC 7807 response (or retain endpoint-specific context) before formatting a run-not-found message.
        if (runId is not null && ex.StatusCode == HttpStatusCode.NotFound)
        {
            return new TelemetryErrorInfo(FormatHistoricalRunNotFound(runId));
        }

src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs:525

  • Older Dashboard telemetry endpoints ignore unknown query parameters, so they accept runId but return current resources and telemetry. Because this helper never verifies run-selection support or the selected run, new CLI/MCP clients can silently diagnose current data as a requested historical run, contrary to the strict no-fallback contract. Add a capability/selected-run check (for example via backchannel info or an echoed API run identity) and reject unsupported Dashboards.
    public static async Task<ResourceInfoJson[]> GetAllResourcesAsync(HttpClient client, string baseUrl, CancellationToken cancellationToken, string? runId = null)
    {
        var url = DashboardUrls.TelemetryResourcesApiUrl(baseUrl, runId);
        var response = await client.GetAsync(url, cancellationToken).ConfigureAwait(false);
        EnsureTelemetryApiResponse(response);

src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:105

  • ExcludeFromMcp promises that a resource is excluded from console-log and telemetry results, but the exclusion check is only executed in the live (runId is null) branch. Supplying any run ID bypasses it and exposes that resource’s retained console logs to the agent. When a backchannel monitor is available, enforce the exclusion before choosing the live or historical transport.
            if (runId is null && _auxiliaryBackchannelMonitor is not null)
            {

src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:218

  • The console-log endpoint also returns 404 when the requested resource does not exist. For a valid historical run plus an unknown resource, this branch incorrectly throws “Dashboard run ... was not found.” Inspect the problem response or validate the resource separately so resource-not-found remains distinguishable.
            if (runId is not null && ex is HttpRequestException { StatusCode: System.Net.HttpStatusCode.NotFound })
            {
                throw new McpProtocolException(TelemetryCommandHelpers.FormatHistoricalRunNotFound(runId), McpErrorCode.InternalError);
            }

src/Shared/DashboardConfigNames.cs:73

  • Interpolated DateTimeOffset formatting uses the current culture. Under a non-Gregorian culture, the automatic ID can use a different calendar year (for example 2569 instead of 2026), violating the documented fixed UTC timestamp format and making IDs locale-dependent. Format invariantly as the previous implementation did.

// PruneRuns, so a non-Gregorian current culture (th-TH, ar-SA) would produce IDs that sort
// against previous runs incorrectly and let retention delete newer runs.
var runId = startedAt.ToString("yyyyMMddTHHmmssfffZ", CultureInfo.InvariantCulture);
var runId = $"{startedAt:yyyyMMddTHHmmssfffZ}";
Copilot AI review requested due to automatic review settings August 6, 2026 10:09
@JamesNK
James Newton-King (JamesNK) force-pushed the jamesnk/dashboard-run-history-agent-access branch from 2230993 to 13adb39 Compare August 6, 2026 10:09
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tests selector (audit mode)

The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement.

53 / 100 test projects · 5 jobs, from 79 changed files.

Selected test projects (53 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Dashboard.Components.Tests, Aspire.Dashboard.Tests, Aspire.EndToEnd.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.GitHub.Models.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Managed.Tests, Aspire.Playground.Tests

Selected jobs (5)

cli-starter, deployment-e2e, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 42 of the 53 selected test projects come from a single change — src/Aspire.Hosting/Aspire.Hosting.csproj.

🔧 src/Aspire.Hosting/Aspire.Hosting.csproj (changed source)
→ 42 via the project graph

show 42

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Garnet.Tests (2 hops), Aspire.Hosting.GitHub.Models.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.JavaScript.Tests (2 hops), Aspire.Hosting.Kafka.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests (2 hops), Aspire.Hosting.MongoDB.Tests (2 hops), Aspire.Hosting.MySql.Tests (2 hops), Aspire.Hosting.Nats.Tests (2 hops), Aspire.Hosting.OpenAI.Tests (2 hops), Aspire.Hosting.Oracle.Tests (2 hops), Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.PostgreSQL.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.Qdrant.Tests (2 hops), Aspire.Hosting.RabbitMQ.Tests (2 hops), Aspire.Hosting.Redis.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Seq.Tests (2 hops), Aspire.Hosting.SqlServer.Tests (2 hops), Aspire.Hosting.Testing.Tests (2 hops), Aspire.Hosting.Valkey.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

🧪 tests/Aspire.Hosting.Tests/Backchannel/AuxiliaryBackchannelRpcTargetTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests
→ 3 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Radius.Tests

🔧 src/Aspire.Dashboard/Api/TelemetryApiService.cs (changed source)
→ 3 via the project graph: Aspire.Dashboard.Components.Tests, Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Managed.Tests (2 hops)

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

📦 affected project Aspire.Hosting
→ 1 test: Aspire.EndToEnd.Tests

🔧 src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs (changed source)
→ 1 via the project graph: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Commands/AgentMcpCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/LogsCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/StartCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Mcp/ListConsoleLogsToolTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Mcp/ListStructuredLogsToolTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Mcp/ListTraceStructuredLogsToolTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Mcp/ListTracesToolTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Dashboard.Tests/Integration/StartupTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Dashboard.Tests/Integration/TelemetryApiTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Dashboard.Tests/Model/DashboardDataSourceTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Hosting.Tests/Dashboard/DashboardEventHandlersTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

Job reasons

Job Triggered by
cli-starter • affected project Aspire.Cli
• selected test Aspire.Cli.Tests
deployment-e2e affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Backchannel/AppHostAuxiliaryBackchannel.cs, src/Aspire.Cli/Commands/AgentMcpCommand.cs, src/Aspire.Cli/Commands/AppHostLauncher.cs, src/Aspire.Cli/Commands/LogsCommand.cs, src/Aspire.Cli/Commands/RunCommand.cs, src/Aspire.Cli/Commands/StartCommand.cs, src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs, src/Aspire.Cli/Commands/TelemetryLogsCommand.cs, src/Aspire.Cli/Commands/TelemetrySpansCommand.cs, src/Aspire.Cli/Commands/TelemetryTracesCommand.cs, src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs, src/Aspire.Cli/Mcp/Tools/ListStructuredLogsTool.cs, src/Aspire.Cli/Mcp/Tools/ListTraceStructuredLogsTool.cs, src/Aspire.Cli/Mcp/Tools/ListTracesTool.cs, src/Aspire.Cli/Mcp/Tools/McpToolHelpers.cs, src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs, src/Aspire.Cli/Resources/RunCommandStrings.resx, src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs, src/Aspire.Cli/Resources/TelemetryCommandStrings.resx, src/Aspire.Cli/Resources/xlf/RunCommandStrings.cs.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.de.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.es.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.fr.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.it.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.ja.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.ko.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.pl.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.pt-BR.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.ru.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.tr.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hans.xlf, src/Aspire.Cli/Resources/xlf/RunCommandStrings.zh-Hant.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.cs.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.de.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.es.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.fr.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.it.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ja.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ko.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.pl.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.pt-BR.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ru.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.tr.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.zh-Hans.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.zh-Hant.xlf, src/Aspire.Dashboard/Api/TelemetryApiService.cs, src/Aspire.Dashboard/Aspire.Dashboard.csproj, src/Aspire.Dashboard/Configuration/DashboardOptions.cs, src/Aspire.Dashboard/Configuration/PostConfigureDashboardOptions.cs, src/Aspire.Dashboard/Configuration/ValidateDashboardOptions.cs, src/Aspire.Dashboard/DashboardEndpointsBuilder.cs, src/Aspire.Dashboard/DashboardWebApplication.cs, src/Aspire.Dashboard/ServiceClient/DashboardDataSource.cs, src/Aspire.Dashboard/ServiceClient/DashboardRunStore.cs, src/Aspire.Hosting/Aspire.Hosting.csproj, src/Aspire.Hosting/Backchannel/AuxiliaryBackchannelRpcTarget.cs, src/Aspire.Hosting/Backchannel/BackchannelDataTypes.cs, src/Aspire.Hosting/Backchannel/DashboardUrlsHelper.cs, src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs, src/Aspire.Hosting/Dashboard/DashboardRunIdentity.cs, src/Aspire.Hosting/DistributedApplicationBuilder.cs, tests/Aspire.Cli.Tests/Commands/AgentMcpCommandTests.cs, tests/Aspire.Cli.Tests/Commands/LogsCommandTests.cs, tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs, tests/Aspire.Cli.Tests/Commands/StartCommandTests.cs, tests/Aspire.Cli.Tests/Mcp/ListConsoleLogsToolTests.cs, tests/Aspire.Cli.Tests/Mcp/ListStructuredLogsToolTests.cs, tests/Aspire.Cli.Tests/Mcp/ListTraceStructuredLogsToolTests.cs, tests/Aspire.Cli.Tests/Mcp/ListTracesToolTests.cs
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit 13adb39.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 81 out of 83 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs: Generated file
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file
Suppressed comments (6)

src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs:357

  • A 404 does not uniquely mean the run is missing: these endpoints also return 404 for an unknown resource or trace, and an older Dashboard/API-disabled route can do the same. For example, a valid run plus a missing trace is now reported as “Dashboard run ... was not found.” Preserve and inspect the RFC 7807 response (or a typed error code) before choosing the run-not-found message.
        if (runId is not null && ex.StatusCode == HttpStatusCode.NotFound)
        {
            return new TelemetryErrorInfo(FormatHistoricalRunNotFound(runId));

src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:217

  • This also treats every historical console-log 404 as a missing run, but /console-logs returns 404 when the requested resource is absent from an existing run. That case now throws the wrong MCP error. Distinguish the API's Run not found ProblemDetails from Resource not found instead of relying only on status code.
            if (runId is not null && ex is HttpRequestException { StatusCode: System.Net.HttpStatusCode.NotFound })
            {
                throw new McpProtocolException(TelemetryCommandHelpers.FormatHistoricalRunNotFound(runId), McpErrorCode.InternalError);

src/Aspire.Dashboard/Api/TelemetryApiService.cs:417

  • The list is built resource-by-resource, so applying Skip here returns the last lines of the last enumerated resource, not the newest matching lines across resources. Consequently, aspire logs --run-id ... --tail N without a resource can omit newer logs from earlier resources. Apply the limit using a globally ordered persisted key/timestamp.
    src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:128
  • This historical/API branch skips the resource.excludeFromMcp check that protects the live branch, so an agent can read excluded console logs by supplying runId. The historical snapshot's exclusion metadata must be enforced before returning logs; checking only the current AppHost model is insufficient when resources or annotations changed between runs.
            else
            {

src/Aspire.Cli/Commands/RunCommand.cs:325

  • This cross-process contract is covered only by mocked CLI unit tests; no test under tests/Aspire.Cli.EndToEnd.Tests uses --run-id. Add a Hex1b E2E scenario that launches a named run, verifies the emitted ID, stops it, and queries its retained telemetry so argument/environment forwarding, Dashboard persistence, backchannel output, and historical lookup are validated together.
            if (runId is not null)
            {
                context.EnvironmentVariables[DashboardConfigNames.DashboardRunIdName.EnvVarName] = runId;
            }

src/Aspire.Hosting/Backchannel/DashboardUrlsHelper.cs:163

  • This unconditionally exposes the precomputed identity when the Dashboard is unhealthy. If the Dashboard process fails before creating its run directory, a normal unnamed launch continues and displays/serializes this RunId even though it cannot be queried. Only expose the run ID after Dashboard health establishes that the persisted run started.

{
public const int MaxLength = 64;

public static string Create(DateTimeOffset startedAt) => $"{startedAt:yyyyMMddTHHmmssfffZ}";
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI review requested due to automatic review settings August 6, 2026 15:21
@JamesNK
James Newton-King (JamesNK) force-pushed the jamesnk/dashboard-run-history-agent-access branch from 13adb39 to 9f1f357 Compare August 6, 2026 15:21
@JamesNK
James Newton-King (JamesNK) force-pushed the jamesnk/dashboard-run-history-agent-access branch from 9f1f357 to 1e5fc30 Compare August 6, 2026 15:31
@JamesNK
James Newton-King (JamesNK) changed the base branch from jamesnk/dashboard-run-history-pinning to jamesnk/dashboard-run-history August 6, 2026 15:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 81 out of 83 changed files in this pull request and generated no new comments.

Files not reviewed (2)
  • src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs: Generated file
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file
Suppressed comments (6)

src/Shared/DashboardConfigNames.cs:73

  • Automatic run IDs are now formatted with the ambient current culture. Under a non-Gregorian culture (for example th-TH), the year can differ from the UTC/Gregorian yyyyMMdd... identifier expected by the storage contract and tests. Format with InvariantCulture, as the extracted code did before this refactor.
    src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs:358
  • A 404 is not sufficient to conclude that the run is missing. For example, aspire otel traces --trace-id missing --run-id valid-run reaches the trace-detail endpoint and receives Trace not found, but this branch reports Dashboard run 'valid-run' was not found; a missing console-log resource is similarly misreported. Preserve or inspect the API problem details (or separately validate the run) before converting the error.
        if (runId is not null && ex.StatusCode == HttpStatusCode.NotFound)
        {
            return new TelemetryErrorInfo(FormatHistoricalRunNotFound(runId));
        }

src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:104

  • The ExcludeFromMcp guard now runs only on the live-backchannel path. Supplying runId takes the HTTP path and returns historical console output for the same resource without checking the exclusion, exposing data that this MCP policy is intended to hide. Perform CheckResourceExcludedAsync before branching whenever a backchannel monitor is available.
            if (runId is null && _auxiliaryBackchannelMonitor is not null)

src/Aspire.Dashboard/Api/TelemetryApiService.cs:417

  • For an all-resource query, logs are appended resource-by-resource and limit is applied only after concatenation. The result is therefore the tail of the last enumerated resource, not the newest matching lines across the run as the API specifies; newer lines from an earlier resource can be discarded. Apply a globally ordered limit, ideally in the repository query.
    src/Aspire.Dashboard/DashboardEndpointsBuilder.cs:318
  • The documented HTTP contract rejects follow=true whenever runId is supplied, but this condition allows streaming when the explicit ID names the current run. This also differs from the CLI, which rejects every --follow --run-id combination. Check the presence of runId, not whether the selected run happens to be historical.
    src/Aspire.Dashboard/Api/TelemetryApiService.cs:395
  • This endpoint can only return console rows that were already copied into SQLite. The only production writes occur when DashboardClient.GetConsoleLogs/SubscribeConsoleLogs is called, so a run whose console stream was never viewed or exported still returns an empty snapshot after the AppHost exits. That leaves the advertised after-the-fact console diagnosis unavailable; persist console streams independently of a live reader before considering the run retained.

Copilot AI review requested due to automatic review settings August 6, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 81 out of 83 changed files in this pull request and generated no new comments.

Files not reviewed (2)
  • src/Aspire.Cli/Resources/RunCommandStrings.Designer.cs: Generated file
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file
Suppressed comments (7)

src/Shared/DashboardConfigNames.cs:73

  • This reintroduces culture-dependent automatic run IDs: interpolated DateTimeOffset formatting uses the current culture, so cultures with non-Gregorian calendars can produce different years and break the durable ID format and chronological ordering. The previous implementation explicitly used invariant culture; preserve that invariant here.
    src/Aspire.Dashboard/Api/TelemetryApiService.cs:395
  • limit is applied only after every matching console line has been materialized. SqliteResourceRepository.GetConsoleLogs already loads each resource's complete log into an array, and this code copies all matches into another list before retaining the tail, so MCP's bounded requests still consume memory proportional to the entire persisted run. Push tail/search filtering into the repository, or maintain a bounded tail while scanning.
    src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs:357
  • A 404 with runId does not prove that the run is missing: the new API also returns 404 for an unknown resource and for an unknown trace. For example, querying a missing trace in a valid historical run now reports that the run was not found. Preserve/inspect the RFC 7807 response or otherwise distinguish run-selection failures before emitting HistoricalRunNotFound.
        if (runId is not null && ex.StatusCode == HttpStatusCode.NotFound)
        {
            return new TelemetryErrorInfo(FormatHistoricalRunNotFound(runId));

src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:134

  • Supplying runId bypasses the ExcludeFromMcp check performed by the live-log branch, exposing historical console logs for resources that explicitly opted out of all MCP results. Apply the same exclusion check before querying the Dashboard whenever a backchannel monitor is available.
                var (apiToken, apiBaseUrl, _) = await _dashboardInfoProvider.GetDashboardInfoAsync(cancellationToken).ConfigureAwait(false);

src/Aspire.Hosting/DistributedApplicationBuilder.cs:221

  • The documented Dashboard:Data:RunId configuration key is ignored here; only the environment-variable key is read. The Dashboard itself gives the config key precedence, so an AppHost configured with Dashboard:Data:RunId=incident-42 will create incident-42 while hosting reports and preflights an unrelated generated timestamp ID. Read both keys with the same precedence and empty-value handling as PostConfigureDashboardOptions.
    src/Aspire.Cli/Mcp/Tools/ListConsoleLogsTool.cs:141
  • resourceName is required for this tool, and MCP resource discovery includes hidden resources, but the historical request excludes them. A resource returned by list_resources can therefore be queried live yet incorrectly return 404 when the same call adds runId. Explicit resource selection should include hidden resources, as LogsCommand already does.
                    includeHidden: false,

src/Aspire.Cli/Commands/AppHostLauncher.cs:83

  • This user-visible launch option has only mocked/unit coverage; there is no CLI E2E test under Aspire.Cli.EndToEnd.Tests proving --run-id survives a real detached launch, appears in JSON output, and can be used to query the retained run after the AppHost stops. That cross-process path spans CLI argument forwarding, environment propagation, hosting preflight, Dashboard storage, backchannel reporting, and the telemetry API, so add a Hex1b E2E scenario covering the advertised agent workflow.
        command.Options.Add(s_runIdOption);

Base automatically changed from jamesnk/dashboard-run-history to main August 25, 2026 05:55
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.6 milestone Sep 3, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants