Add experimental next-action extension prototype - #4746
Open
anujb-msft wants to merge 1 commit into
Open
Conversation
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
Contributor
There was a problem hiding this comment.
🟡 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(); |
This was referenced Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, anddoes not modify the installed CLI.
joinSession()and a no-toolsui.ephemeralQuery; do not launch another CLI or request credentials.form followed by a separate editable submission form.
/next-action 1to preview,/next-action run 1 [edited prompt]to submit, and/next-action doneto dismiss.Selection alone never starts another task.
invalid output, and unsupported models. Bound the caller's wait without
pretending that timeout cancels the underlying model request.
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 testpasses all 57 tests. The tests useinjected 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.