Skip to content

[1/3] Add shared structured action discovery and contracts - #2991

Open
George Ng (GeorgeNgMsft) wants to merge 1 commit into
mainfrom
georgengmsft-structured-action-contracts
Open

[1/3] Add shared structured action discovery and contracts#2991
George Ng (GeorgeNgMsft) wants to merge 1 commit into
mainfrom
georgengmsft-structured-action-contracts

Conversation

@GeorgeNgMsft

@GeorgeNgMsft George Ng (GeorgeNgMsft) commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

This PR gives Copilot a shared way to discover what TypeAgent can do and look up the information needed to use a specific action: its inputs, current availability, and whether user confirmation is required. It also adds a way to detect when an action's definition has changed, so later calls can avoid using outdated instructions. This is the foundation for calling actions directly; it does not execute them yet or change how ordinary natural-language requests work.

Summary

Adds the shared discovery and contract foundation for structured action invocation from Copilot into TypeAgent. This is layer 1 of 3 in the refactor of #2973, following the canonical design.

Direct and MCP integrations will use the same dispatcher service rather than implementing their own discovery or serializing actions into command strings.

Changes

  • Two-level discovery: Dispatcher.searchActions(request?) returns compact, filterable action summaries; Dispatcher.getActionContract({ schemaName, actionName }) retrieves one contract directly by exact identity. Both methods are wired through the existing dispatcher RPC client and server.
  • Closed action contracts: reuse the existing schema parser, serializer, and TypeScript generator to include the selected action's required/optional parameters and transitive referenced types, including nested objects, enums, and recursive references. Unrelated sibling actions and internal parser types are not exposed.
  • Versioning and scope: responses include protocol version 1, an opaque scope identifier, and a semantic contract fingerprint. Fingerprints cover execution-relevant schema and policy, excluding descriptions and transient availability. Trusted logical bindings can retain their scope across authorized reconnects; distinct sessions, bindings, and anonymous facades remain isolated.
  • Conservative effect policy: optional SchemaManifest.actionPolicies metadata defaults to unknown effects requiring confirmation. Only an explicitly declared read-only action is exempt, unless its policy explicitly requires confirmation. No agents are speculatively classified.
  • Honest availability and results metadata: report exact schema/action enablement and cached readiness without enabling agents, running setup, or probing readiness. Command enablement does not imply action availability. Contracts describe the standard ActionResult envelope, leave agent-specific result values explicitly unknown, and acknowledge possible runtime interactions.
  • Trusted visibility: host-supplied schema restrictions are applied before parsing or disclosure. Scope identifiers are reuse boundaries, not authorization grants; owning-service authentication and resource authorization remain execution-time requirements.

Stack boundary

This PR exposes discovery only. It does not add action execution, continuation/cancellation endpoints, command-string wrappers, per-action MCP tools, or a batch/plan API. Existing natural-language behavior is unchanged.

Layer 2 adds guarded execution, stale-contract rejection, confirmation, structured results, and interaction lifecycle handling. Layer 3 adds thin Direct/MCP integrations over that same service, conversation mapping, and integration guidance.

Validation

  • Dispatcher and dispatcher-RPC builds passed.
  • 94 dispatcher tests passed across structured-action discovery, readiness, describe, and schema-cache suites.
  • 18 dispatcher RPC tests passed.
  • Committed-diff lint, complexity, circular-dependency, and test-debt ratchets passed against origin/main.
  • Changed-file formatting passed.

Coverage includes exact identity resolution, dependency closure and sibling exclusion, optional parameters, recursive types, semantic fingerprint changes versus description/readiness changes, conservative confirmation defaults, visibility filtering before parsing, unavailable states without probes or effects, trusted reconnect scope reuse, and RPC forwarding/error propagation.

Expose exact action discovery and closed TypeScript contracts through Dispatcher and RPC. Fingerprint execution-relevant schema and policy, report cached availability, and support trusted logical scope reuse without enabling execution.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title Structured action contracts [1/3] Structured action contracts Sep 11, 2026
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title [1/3] Structured action contracts [1/3] Add shared structured action discovery and contracts Sep 11, 2026
@GeorgeNgMsft
George Ng (GeorgeNgMsft) added this pull request to stack #2994 September 11, 2026 07:20
@GeorgeNgMsft
George Ng (GeorgeNgMsft) marked this pull request as ready for review September 11, 2026 18:30
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.

1 participant