Skip to content

agentHost: Support typed repository source session creation - #336361

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

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

Conversation

@osortega

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

Copy link
Copy Markdown
Contributor

Summary and dependency

Support optional repository-backed session creation through the typed contract in microsoft/agent-host-protocol#451. The protocol mirror is pinned to fa44ef3fae7c4750012024c106b70577e7a027c4.

{
  "repositorySource": "https://git.example.org/team/app.git",
  "repositoryRevision": "main",
  "config": { "mode": "interactive" }
}

Source and revision are top-level typed fields on creation and config queries, not entries in config. They are also immutable session metadata, separate from host-resolved working directories. One source can resolve to several directories or different worktrees across sessions.

Supersedes the closed #336294. This PR does not expose arbitrary RPC dispatch or implement a vendor cloning adapter.

Changes

  • Discover per-agent capabilities.repositorySource; {} supports a source and { "revision": true } also supports an explicit revision. No source config-key convention or property-name mapping remains.
  • Carry typed source/revision through internal agent APIs, wire serialization, metadata/list projections, Sessions creation options and chat requests. Source identity is not rewritten as a filesystem URI.
  • Expose provider-neutral source/revision capability flags on Sessions types. Reject unsupported types, revision-only/quick-chat requests, invalid values, and the obsolete config carrier instead of choosing a default directory.
  • Resolve provider configuration using typed repository context and preserve the host's authoritative normalized values.
  • Resolve repository drafts without starting preparation; first Send starts creation through the shared handler. Ordinary directory drafts retain eager creation.
  • Wait for Ready with matching source/revision and resolved directories before sending the first turn. Lost-reply recovery compares exact intent, including an omitted revision, and does not attach active-client reconciliation to an unverified repository session.
  • Use profile-only customization scope during preparation, then rebind to resolved roots after readiness/identity checks and local workspace trust. Cancelling a local wait does not dispose the shared host session.
  • Preserve operation-neutral progress and explicit failure reporting. The native VS Code host does not advertise repository preparation and rejects these inputs; supporting remote hosts own preparation.

No new clone RPC, token-provisioning change, lifecycle state or protocol-version bump.

Reading order

  1. Typed validation helper, agent API types, and wire client.
  2. Repository configuration/readiness helper and session handler.
  3. Sessions provider plumbing and repository regression tests.

Validation of 9c6764a395581406c761ca3b0a91870ff0a9d89d

  • 84 focused tests passed against the final protocol mirror, covering capability discovery, typed transport/metadata, unsupported native-host input, provider routing, configuration, readiness/recovery, cancellation, trust, customization scope, progress and legacy directory behavior.
  • npm run typecheck-client and npm run valid-layers-check passed.
  • Changed-file hygiene/ESLint, patch checks and normal commit hooks passed.
  • Typecheck and tests ran on the production-only source tree, with the temporary picker overlay removed. Tests used isolated transpiled output, not the running development build.

Scope and verification limits

  • Intentionally draft pending protocol review and coordinated adoption.
  • No production repository picker is included. The existing temporary local input command remains uncommitted and unpushed. Generic Sessions capability/input plumbing and first-send preparation are included.
  • Earlier manual testing used descriptor-era host/client builds. It does not establish live interoperability for this typed-field revision; that environment was not rebuilt or restarted.
  • Hosts and clients using earlier unreleased drafts need coordinated updates. Released-binary compatibility and deployment rollout are not verified.
  • No full application build, live sandbox, UI or end-to-end scenario was run for this update. Live failure/cancellation/reconnect and workspace-scoped customization/trust behavior still need human verification against a supporting host. Earlier CI/reviews apply only to their original revisions.

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>
Use repositorySource and repositoryRevision from advertised session configuration instead of a field-name descriptor. Preserve directory-only compatibility and requested intent through readiness and lost-response recovery, and reject unsupported explicit inputs.

Sync the AHP contract from b6a62eba9b67cbe3252682e9d6a4255d3e1175c6. Keep the local integration UI patch outside this commit.

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

Copilot-Session: 79731f48-d288-483f-8809-136aa141d1eb
@osortega Osvaldo Ortega (osortega) changed the title agentHost: Use schema-driven repository session creation agentHost: Use standard repository source configuration Sep 17, 2026
@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Base: 6ce08fd7 Current: 517ac0b3

No screenshot changes.

Move repository intent out of provider config and carry typed source/revision fields through creation, queries, session metadata and recovery. Discover support through per-agent capabilities and reject unsupported native-host requests. Prepare source drafts on first send while preserving eager directory creation, trust checks and customization rebinding. Verify exact recovery intent, including an omitted revision.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 79731f48-d288-483f-8809-136aa141d1eb
@osortega Osvaldo Ortega (osortega) changed the title agentHost: Use standard repository source configuration agentHost: Support typed repository source session creation Sep 18, 2026
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