Skip to content

Source agreement state - #6612

Open
JohnMcPMS wants to merge 7 commits into
microsoft:masterfrom
JohnMcPMS:source-agreement-state
Open

JohnMcPMS wants to merge 7 commits into
microsoft:masterfrom
JohnMcPMS:source-agreement-state

Conversation

@JohnMcPMS

@JohnMcPMS JohnMcPMS commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

📖 Description

Expose source agreement state through COM and leverage it in the MCP server to handle source and package agreements.

This leverages elicitation when available, which allows the server to ask the user to make a decision directly. When not available, unaccepted agreements are simply returned as a response so that the agent can present them / submit a new tool call with the agreements field set to true.

🔍 Validation

Add tests for the COM interface additions and MCP server tests.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS
JohnMcPMS requested a review from a team as a code owner October 23, 2026 17:49

@ranm-msft ranm-msft 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.

Holding approval for two agreement-consent paths.

  1. Fail closed when source agreement state cannot be read.
  2. Present the complete terms for text-only agreements.

// Reading the agreements requires contacting the source. Rather than turn a transient
// failure into a confusing agreement error, use the catalog and let connecting to it
// report the actual problem.
selection.Included.Add(catalog);

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.

This fails open on agreement-state retrieval: a transient information-endpoint failure adds the catalog, Connect retries the same REST reference, and AcceptSourceAgreements defaults true, so the recovered source can be searched or installed from without presenting its agreements. Please fail or exclude this source until its agreement state can be read successfully.

if (agreement.Text.Length > MaximumAgreementTextLength)
{
// The full text remains available at the URL, which follows when present.
message.Append(agreement.Text, 0, MaximumAgreementTextLength);

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.

This can let the user accept a valid text-only agreement after seeing only its first 2,000 characters; agreement text may be 10,000 characters and the URL is optional, while accepted elicitation proceeds without invoking the full-text fallback. Please only truncate when the complete terms remain accessible, or present the full text before accepting.

@ranm-msft ranm-msft 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.

The source-agreement tests need deterministic cleanup before I can sign off.

[TearDown]
public void TearDown()
{
CleanupTestPackages();

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.

Both x64 and x86 CI time out here after SourceAgreements_Elicitation_Declined leaves TestMCPAgreementsRestSource installed with changed, unaccepted agreements. Because agreementsSource.Remove() follows CleanupTestPackages() in both teardown and setup, the first uninstall timeout prevents source removal and later agreement cases repeat the timeout during setup. Remove the agreement source before running winget uninstall, and ensure source removal still runs if package cleanup throws.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants