Skip to content

agentHost: Use schema-driven repository session creation - #336361

Draft
Osvaldo Ortega (osortega) wants to merge 2 commits into
mainfrom
agents/repository-session-config
Draft

Osvaldo Ortega (osortega) wants to merge 2 commits into
mainfrom
agents/repository-session-config

Conversation

@osortega

@osortega Osvaldo Ortega (osortega) commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Draft and dependency

Depends on the proposed public contract in microsoft/agent-host-protocol#451 (synced from 5eadbe33f6048f748fe42a0a125b96e91414bfdc). Keep this draft pending protocol review and a host implementing that contract.

Supersedes the closed #336294. This replacement starts from current main; it does not carry the vendor-cloning adapter or arbitrary RPC dispatch API.

Summary

  • Discover repository intent through optional SessionConfigSchema.repository, using host-chosen URL and revision property IDs instead of a vendor method or hardcoded configuration names.
  • Forward the selection through ordinary session config and createSession; the host owns checkout preparation. Existing directory behavior remains when the descriptor is absent, including hosts without configuration discovery.
  • Wait for repository-backed sessions to publish ready/failed state and resolved directories before the first turn. Reattach after an existing-session response only when the published repository intent matches the requested source and explicit revision.
  • Rebind customization scopes to the resolved checkout and preserve workspace-trust checks for newly prepared local directories. Cancelling the client wait does not dispose shared host resources.
  • Render generic preparation progress without assuming that indeterminate values are download bytes.
  • Sync the additive proposed AHP schema and document the client lifecycle. No clone RPC, provider-name check, token-provisioning change, new lifecycle state, or protocol-version bump.

Validation

  • 90 targeted tests passed across repository configuration, creation/readiness, lost-response recovery, checkout trust, customizations, and progress.
  • npm run typecheck-client passed.
  • Changed-file ESLint and npm run valid-layers-check passed.
  • Staged hygiene, commit hooks, and git diff --check passed.

Manual / interoperability verification still needed

  • Start a repository-backed session on a supporting host and verify its resolved directory before the first turn.
  • Verify a second client can join during preparation and after readiness.
  • Exercise creation failure, lost replies, cancellation, and reconnect with the concrete host.
  • Verify an older host still follows its supported directory-based path.
  • Verify workspace-scoped MCP configuration and local checkout trust in the UI.

No full build, live sandbox, or released-client binary compatibility run was performed. Test results are unit/simulated contract evidence, not a production rollout guarantee.

Consume the optional repository descriptor proposed in microsoft/agent-host-protocol#451. Forward selected repository intent through session configuration, leaving checkout preparation to the host and retaining legacy directory behavior when the descriptor is absent.

Wait for repository readiness and resolved directories before sending a turn, rebind customization scopes, preserve local workspace trust, and verify repository intent when recovering an existing session. Render preparation progress without assuming download units.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Copilot review overview

🟡 Changes recommended

Repository configuration authority, recovery validation, trust gating, and pre-validation reconciliation have correctness issues.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 4 Medium severity

Open (4)
What changed in this PR

Adds schema-driven repository session creation through the Agent Host Protocol.

Changes:

  • Discovers repository URL/revision fields and waits for checkout readiness.
  • Rebinds customization scopes and validates checkout trust.
  • Generalizes preparation progress and syncs protocol documentation/types.
File Description
agentHostRepositoryConfig.test.ts Tests repository configuration and readiness.
agentHostDownloadProgress.test.ts Tests generic progress messaging.
agentHostChatContribution.test.ts Tests creation, recovery, trust, and customizations.
agentHostSessionHandler.ts Integrates repository-backed creation lifecycle.
agentHostRepositoryConfig.ts Implements schema discovery and readiness validation.
agentHostDownloadProgress.ts Makes progress rendering operation-neutral.
REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md Documents repository session lifecycle.
channels-session/​state.ts Adds repository schema metadata.
channels-session/​commands.ts Documents creation requirements.
channels-root/​notifications.ts Clarifies progress semantics.
channels-root/​commands.ts Exports and documents repository configuration.
.ahp-version Updates the synchronized protocol revision.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if (!confirmed || confirmed.urlProperty !== descriptor.urlProperty || confirmed.revisionProperty !== descriptor.revisionProperty) {
throw new Error(localize('agentHost.repositoryConfigChanged', "The agent host changed its repository configuration while resolving the session."));
}
return { ...resolved.values, ...requested };
Comment on lines +114 to +119
const revisionProperty = readRepositorySessionConfig(state.config?.schema)?.revisionProperty;
const expectedRevision = revisionProperty ? expectedConfig?.[revisionProperty] : undefined;
const actualRevision = revisionProperty ? state.config?.values[revisionProperty] : undefined;
if (state.lifecycle !== SessionLifecycle.Ready || !repository
|| (expectedRepository && repository !== expectedRepository.toString())
|| (expectedRevision !== undefined && actualRevision !== expectedRevision)
Comment on lines +5611 to +5612
if (requestedDirectory?.scheme === Schemas.https && defaultScheme !== Schemas.https) {
const repositoryConfig = await resolveAgentHostRepositoryConfig(this._config.connection, this._config.provider, requestedDirectory, config, cancellationToken);
}

const rawState = this._requireRawSessionState(session.toString());
const rawState = await waitForRepositorySessionReady(newSub, cancellationToken, repository, config);
Use the host's re-resolved defaults after selecting a repository, rather than restoring defaults from the previous context. Preserve explicit user selections and add a regression test for removed and changed defaults.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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