Skip to content

Add experimental next-action extension prototype - #4746

Open
anujb-msft wants to merge 1 commit into
github:mainfrom
anujb-msft:feat/next-action-extension-prototype
Open

Add experimental next-action extension prototype#4746
anujb-msft wants to merge 1 commit into
github:mainfrom
anujb-msft:feat/next-action-extension-prototype

Conversation

@anujb-msft

Copy link
Copy Markdown

Summary

Add an opt-in, experimental SDK extension example for model-inferred next actions.
It lives under examples/next-best-action/, outside extension auto-discovery, and
does not modify the installed CLI.

  • Reuse the existing foreground session through joinSession() and a no-tools
    ui.ephemeralQuery; do not launch another CLI or request credentials.
  • Offer up to three validated, ranked prompts. Interactive mode uses a choice
    form followed by a separate editable submission form.
  • Keep autopilot enabled with a non-modal list, /next-action 1 to preview,
    /next-action run 1 [edited prompt] to submit, and /next-action done to dismiss.
    Selection alone never starts another task.
  • Guard empty context, stale results, concurrent requests, duplicate submission,
    invalid output, and unsupported models. Bound the caller's wait without
    pretending that timeout cancels the underlying model request.
  • Include installation/compatibility documentation, dependency-free tests, and a
    read-only, path-scoped CI workflow for Node 20, 22, and 24.

Scope

This is a working extension prototype, not native Tab ghost text or an
automatically opened post-goal menu. Those interfaces need host integration and
are deliberately not represented as implemented here. The example provides a
concrete interaction and inference path for that discussion.

Related to #1336; this does not claim to close the broader actionable-output request.

Validation

npm --prefix examples/next-best-action test passes all 57 tests. The tests use
injected session APIs, require no package installation, and make no model requests.

Local terminal exercises also covered an empty session with zero inference calls,
a normal user-entered task followed by live suggestions with no forced model,
interactive selection/edit/cancel, and autopilot list/preview/explicit submission.
Recommendation submission was captured at the boundary rather than allowed to
execute arbitrary follow-up work. Mode and permission state stayed unchanged
through the suggestion flow.

Compatibility and usage caveats

The extension requires a CLI build exposing the experimental SDK APIs documented
in the example. It handles completed streamed answers when the RPC answer is empty,
and reports provider errors without switching models or retrying automatically.
Queries may incur model usage. Per-query cancellation and enforcement of the main
turn's usage limit are not claimed; native automatic inference should not be enabled
until those lifecycle and accounting guarantees are available.

Provide same-session follow-up recommendations with separate preview and submission, context and inference guards, documentation, and dependency-free regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 10b8045a-e3a6-4437-958a-dc94b06dff36
@anujb-msft
anujb-msft requested review from a team and a balanced review from Copilot September 7, 2026 05:27

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.

🟡 Changes recommended

The stream fallback can incorrectly accept an unrelated side query’s response.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an opt-in next-action extension prototype using the active Copilot CLI session.

Changes:

  • Adds validated, cached next-action inference and interactive/autopilot workflows.
  • Adds documentation and 57 dependency-free tests.
  • Adds path-scoped CI for Node.js 20, 22, and 24.
File summaries
File Description
README.md Links the experimental example.
.github/workflows/next-action-extension.yml Runs the example’s test matrix.
examples/next-best-action/README.md Documents installation, behavior, and limitations.
examples/next-best-action/package.json Defines the test command and runtime requirement.
examples/next-best-action/extensions/next-best-action/extension.mjs Joins the foreground session.
examples/next-best-action/extensions/next-best-action/recommendations.mjs Validates, caches, and times out recommendations.
examples/next-best-action/extensions/next-best-action/session-adapter.mjs Implements command, tool, and UI workflows.
examples/next-best-action/extensions/next-best-action/session-query.mjs Adapts RPC and streamed query responses.
examples/next-best-action/test/next-action.test.mjs Tests recommendation and interaction behavior.
examples/next-best-action/test/session-query.test.mjs Tests query and stream handling.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +94 to +97
if (ambiguous || streams.size !== 1) {
throw new Error("Concurrent side queries made the streamed recommendation ambiguous. Request it again when other queries finish.");
}
const [stream] = streams.values();
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