Skip to content

SDK: Add scoped main-turn interruption#2014

Closed
SlowGreek wants to merge 2 commits into
github:mainfrom
SlowGreek:slowgreek-add-scoped-main-turn-interrupt
Closed

SDK: Add scoped main-turn interruption#2014
SlowGreek wants to merge 2 commits into
github:mainfrom
SlowGreek:slowgreek-add-scoped-main-turn-interrupt

Conversation

@SlowGreek

@SlowGreek SlowGreek commented Jul 17, 2026

Copy link
Copy Markdown

Summary

  • generate the typed session.interruptMainTurn Rust RPC surface from github/copilot-agent-runtime#12968 final head 9391d2e781b23fc1ebcbd5b4605f848afa40b7d0
  • add Session::interrupt_main_turn(InterruptMainTurnOptions), InterruptMainTurnRequest, InterruptMainTurnResult, and SessionCapabilities::interrupt_main_turn
  • decode interruptMainTurn through generated CapabilitiesChangedData and replace the live capability cache from each complete capabilities.changed snapshot
  • keep session.abort recursive/destructive and propagate -32601 without any abort fallback
  • cover omitted/false/true flushQueued, both interruption results, create/resume/change capabilities, older servers, unsupported methods, and typed event decoding
  • document foreground interruption versus recursive abort in the Rust README

Final-head parity

The generated Rust files were produced from the committed API and session-event schemas at runtime head 9391d2e781b23fc1ebcbd5b4605f848afa40b7d0. These files are byte-identical to draft SDK PR #2015:

  • rust/src/generated/api_types.rs
  • rust/src/generated/rpc.rs
  • rust/src/generated/session_events.rs

PR #2014 additionally retains the broader regression matrix and README coverage.

Mixed-version behavior

Older CLIs and unsupported remote sessions return JSON-RPC MethodNotFound (-32601). The Rust API propagates that error exactly and never falls back to session.abort. A missing capability is None, local support is Some(true), and unsupported remote support is Some(false).

capabilities.changed is a complete SessionCapabilities snapshot at the final runtime contract, so the SDK intentionally replaces rather than sparsely merges its cache.

Publication gate

The current SDK pin remains @github/copilot 1.0.71, which does not contain the method; CLI/package 1.0.72-0 also predates the final runtime head. Once the first containing package is published, the only remaining gate is to update the repository-standard dependency/version/hash pins and rerun canonical full codegen from that package. Until then, the codegen freshness check is expected to remain blocked.

Validation

  • final-head Rust codegen repeat-generation stability and byte parity with draft PR Rust: Add Scoped Main-Turn Interruption #2015
  • cargo test --features test-support --test session_test (118 passed)
  • cargo clippy --all-targets --features test-support,bundled-in-process -- --no-deps -D warnings -D clippy::unwrap_used -D clippy::disallowed_macros -D clippy::await_holding_invalid_type
  • RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --all-features

Prerequisite for github/github-app#8664 and github/github-app#9104.

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

Copilot-Session: a1e1fcdd-b581-4c40-90e3-bde51729fd00
@SlowGreek
SlowGreek requested a review from a team as a code owner July 17, 2026 01:13
Copilot AI review requested due to automatic review settings July 17, 2026 01:13
@SlowGreek

Copy link
Copy Markdown
Author

Maintainer action requested: this PR is the canonical SDK/codegen prerequisite for github/copilot-agent-runtime#12968 and github/github-app#8664. The author account has READ permission in this repository, so it cannot enable merge-queue auto-merge. Once the final containing CLI package is pinned, canonical codegen is fresh, required checks pass, and review conversations are resolved, please enable repository auto-merge/merge queue. The hourly steward will keep the branch current and address CI/review feedback; no protection bypass is requested.

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.

Pull request overview

Adds Rust SDK support for scoped main-turn interruption while preserving background work.

Changes:

  • Adds typed interruption RPC types and Session::interrupt_main_turn.
  • Exposes interruption capability state.
  • Adds documentation and protocol/capability tests.
Show a summary per file
File Description
rust/src/session.rs Adds the high-level interruption API.
rust/src/types.rs Exposes request, result, and capability types.
rust/src/generated/rpc.rs Adds generated typed RPC dispatch.
rust/src/generated/api_types.rs Adds generated protocol types and constants.
rust/tests/session_test.rs Tests RPC and capability behavior.
rust/tests/e2e/elicitation.rs Updates capability construction.
rust/README.md Documents interruption usage.

Review details

  • Files reviewed: 5/7 changed files
  • Comments generated: 2
  • Review effort level: Medium

.await
.expect("replacement capabilities should update within timeout");

assert!(caps.ui.is_none());

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final runtime contract at 9391d2e781b23fc1ebcbd5b4605f848afa40b7d0 makes every capabilities.changed payload a complete SessionCapabilities snapshot, matching create/resume/getForeground. A sparse merge would retain stale capabilities after the host removes one, so wholesale replacement is intentional. The updated regression test now receives a full { interruptMainTurn: true, ui: ... } snapshot followed by a full { interruptMainTurn: false } snapshot and verifies that the omitted UI capability is removed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final runtime contract clarification: every capabilities.changed payload is a complete snapshot, so wholesale replacement is intentional. Canonical PR #2015 now documents and tests replacement (including clearing omitted prior UI state) at 6b5ad304; partial merge semantics must not be carried forward. #2014 is superseded after this parity transfer.

Comment on lines 3237 to 3241
"capabilities.changed",
serde_json::json!({
"interruptMainTurn": true,
"ui": { "elicitation": true }
}),

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by regenerating rust/src/generated/session_events.rs from the final runtime session-event schema at 9391d2e781b23fc1ebcbd5b4605f848afa40b7d0. CapabilitiesChangedData now exposes interrupt_main_turn: Option<bool>. The test subscribes to the event stream, decodes both notifications through event.typed_data::<CapabilitiesChangedData>(), and asserts the typed true/false values before checking the live cache. All three generated Rust files are byte-identical to draft PR #2015.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dedup update: draft PR #2015 is now the canonical SDK lane. Its rust/src/generated/session_events.rs, generated from final runtime head 9391d2e781b23fc1ebcbd5b4605f848afa40b7d0, exposes CapabilitiesChangedData::interrupt_main_turn and supersedes this PR’s older generated event surface. The stronger typed-event regression coverage and complete-snapshot rationale are being transferred there; no further code changes will be made on #2014.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in canonical PR #2015: its final-head generated session_events.rs exposes CapabilitiesChangedData::interrupt_main_turn: Option<bool>, and 6b5ad304 adds an explicit event.typed_data::<CapabilitiesChangedData>() assertion. #2014 is superseded after this parity transfer.

@SlowGreek

Copy link
Copy Markdown
Author

Canonical SDK lane: this PR will absorb the final runtime-head codegen from draft #2015 (c744d351, runtime 9391d2e781), including generated session_events capability decoding and the final InterruptMainTurnOptions { flush_queued } surface, while preserving this PR’s richer tests and README. #2015 will close only after parity is verified. The containing CLI package/pin remains the final codegen-freshness gate.

@SlowGreek

Copy link
Copy Markdown
Author

Canonical-lane correction after final-head comparison: draft #2015 is now canonical because it is generated from runtime 9391d2e781, includes the final typed CapabilitiesChangedData::interrupt_main_turn event surface, and uses the repository-conventional InterruptMainTurnOptions API. This PR is frozen while its stronger wire/result/error/capability tests and README documentation are transferred to #2015. It will close as superseded only after parity is verified.

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

Copilot-Session: a1e1fcdd-b581-4c40-90e3-bde51729fd00
@SlowGreek

Copy link
Copy Markdown
Author

Final dedup decision and parity confirmation: PR #2014 is canonical. Head 7d7327bdc1ba834bdace8c2ee7f6f1a9b1d407b0 now contains every final-head behavior from draft #2015 (c744d351, runtime 9391d2e781): all three generated Rust files are byte-identical, InterruptMainTurnOptions and the final high-level signature are present, typed CapabilitiesChangedData::interrupt_main_turn decoding is covered, and the non-exhaustive capability/options API plus corrected E2E fixture are included. #2014 also retains its broader wire/mixed-version/snapshot tests and README. The earlier interim comment naming #2015 canonical is superseded; #2015 may now be closed by the dedup owner. The first containing CLI package/pin remains the sole expected codegen-freshness gate.

SlowGreek pushed a commit to SlowGreek/copilot-sdk that referenced this pull request Jul 17, 2026
Transfer the stronger wire, error, capability, typed-event, and queue-semantics coverage from superseded PR github#2014 while preserving the final-runtime-head generated schema and conventional high-level API.

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

Copilot-Session: 52417727-d5b4-482e-8391-0011d0984a5d
@SlowGreek

Copy link
Copy Markdown
Author

Parity is now verified in canonical draft #2015 at 6b5ad304; generated final-runtime-head schema is preserved and all stronger #2014 docs/tests have been transferred. The complete-snapshot and typed-event review threads are answered above. This PR is ready to close as superseded once the coordinating parent records the handoff.

@SlowGreek

Copy link
Copy Markdown
Author

Superseded by canonical PR #2015. #2015 is generated from final runtime head 9391d2e781, contains byte-identical final generated RPC/event surfaces, and now includes this PR’s stronger README, wire/result/error/capability, typed-event, and no-abort-fallback coverage at head 6b5ad304. The release pin/full canonical codegen and ongoing maintenance continue there.

@SlowGreek SlowGreek closed this Jul 17, 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.

3 participants