Upstream sync: post-v1.0.0-beta.4 round 4 (schema 1.0.52-1, #1366)#110
Merged
Conversation
Additive schema changes: - session.compaction_complete-data: +:custom-instructions (optional string) - tool.execution_complete-data: +:sandboxed (optional boolean) - session.shutdown-data: :total-premium-requests moved from :req-un to :opt-un (relaxation) All other diffs are description / x-opaque-json annotation churn that does not affect the generated specs. Regenerated event_specs.clj and coerce.clj via 'bb codegen'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add support for the new preMcpToolCall hook type that fires before an
MCP tool call is dispatched. The hook can inspect, modify, or remove
the outgoing MCP request _meta via a tri-state :meta-to-use field.
Wire conversion changes (protocol.clj):
- Incoming escape hatch on hooks.invoke + hookType=preMcpToolCall:
preserve :arguments and :_meta as opaque verbatim payloads. csk would
also collapse :_meta to :meta, so we explicitly dissoc :meta and
re-assoc :_meta to preserve the leading underscore.
- Outgoing escape hatch on hooks.invoke responses: when the result map
contains :meta-to-use (checked via contains?, not truthiness), translate
the key to :metaToUse and preserve the inner map verbatim so MCP-source
keys are not camelCased. The contains? check makes the explicit-null
case round-trip as JSON null (the runtime tri-state contract for
removing _meta vs preserving it vs replacing it).
Tests cover:
- input shape (kebab-cased base fields, opaque :arguments / :_meta);
- output {:meta-to-use {…}} → metaToUse with inner keys preserved;
- output {:meta-to-use nil} → metaToUse: null on the wire;
- output {} / nil → no metaToUse key on the wire.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Upstream schema 1.0.52-1 made totalPremiumRequests optional on the session.shutdown event (regenerated event_specs.clj already reflects this in :opt-un). The hand-curated idiom spec was still requiring it, which would reject otherwise-valid 1.0.52+ CLI shutdown events at the public API boundary. Reviewer finding (GPT-5.5 multi-model review). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Round-4 upstream sync against @github/copilot schema 1.0.52-1 and Node.js SDK v1.0.0-beta.6, adding the upstream PR #1366 preMcpToolCall hook and aligning curated specs with regenerated wire schemas.
Changes:
- Bumped pinned Copilot schemas to
1.0.52-1and regenerated generated wire event specs. - Added new lifecycle hook
:on-pre-mcp-tool-callwith explicit preservation of opaque:argumentsand:_meta, plus tri-state outgoing:meta-to-use→metaToUsebehavior. - Relaxed curated idiom spec for
::session.shutdown-datato make:total-premium-requestsoptional (matching the updated schema).
Show a summary per file
| File | Description |
|---|---|
| test/github/copilot_sdk/integration_test.clj | Adds integration tests covering preMcpToolCall hook input shape and meta-to-use tri-state output wiring. |
| src/github/copilot_sdk/specs.clj | Extends ::hooks spec with ::on-pre-mcp-tool-call and relaxes ::session.shutdown-data. |
| src/github/copilot_sdk/session.clj | Routes "preMcpToolCall" hookType to :on-pre-mcp-tool-call handler key. |
| src/github/copilot_sdk/protocol.clj | Preserves opaque incoming :arguments/:_meta for preMcpToolCall and preserves outgoing :meta-to-use inner keys without camel-casing. |
| src/github/copilot_sdk/generated/event_specs.clj | Regenerated wire event specs reflecting schema 1.0.52-1 additive updates. |
| src/github/copilot_sdk/client.clj | Updates create-session docstring to document the new hook and its meta-to-use contract. |
| schemas/session-events.schema.json | Updated vendored upstream schema (opaque-json annotations + additive fields + shutdown required relaxation). |
| schemas/api.schema.json | Updated vendored upstream schema (adds secrets RPC + opaque-json annotations + other upstream schema tweaks). |
| schemas/README.md | Updates pinned schema version text to 1.0.52-1. |
| doc/reference/API.md | Documents :on-pre-mcp-tool-call hook usage and input/output behavior. |
| CHANGELOG.md | Adds Unreleased entries for the new hook and schema bump, including deferrals context. |
| .copilot-schema-version | Bumps pinned schema version to 1.0.52-1. |
Copilot's findings
- Files reviewed: 11/12 changed files
- Comments generated: 0
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.
Round-4 sync against upstream github/copilot-sdk
v1.0.0-beta.6. The session plan lives in~/.copilot/session-state/c6cf4b0c-f936-4106-ba24-5201cfdd5e2d/plan.md.Changes (3 logical commits)
1.
chore(codegen): schema bump 1.0.51 → 1.0.52-1Regenerated
event_specs.cljandcoerce.cljviabb codegen. Additivechanges only:
session.compaction_complete-datagains optional:custom-instructionstool.execution_complete-datagains optional:sandboxedsession.shutdown-datarelaxes:total-premium-requestsfrom required to optional2.
feat(hooks)::on-pre-mcp-tool-callhook (upstream PR #1366)New
:hooksentry that fires before an MCP tool call is dispatched.:server-name,:tool-name,:tool-call-id,:session-id,:timestamp,:cwd) plus two opaquefields preserved verbatim through wire normalization:
:arguments(MCP tool args) and
:_meta(MCP request metadata; leadingunderscore preserved despite csk's default collapse).
:meta-to-use:{}→ preserve existing_meta{:meta-to-use {…}}→ replace_metawith the given map; innerkeys are NOT camelCased (opaque payload)
{:meta-to-use nil}→ JSONnullon the wire (remove_meta)Wire conversion lives in
protocol.clj:normalize-incomingadds a per-method/per-hookType escapehatch that re-keys
:argumentsand:_metaverbatim from the rawparams, sidestepping csk recursion.
preserve-outgoing-opaque-fieldsusescontains?(nottruthiness) on
:meta-to-useso explicit nil survives as JSON null.3.
fix(specs): align::session.shutdown-datawith relaxed schemaGPT-5.5 review caught that the hand-curated idiom spec still required
:total-premium-requestsafter the schema relaxed it.Validation
bb test— 274 tests, 1303 assertions, 0 failures, 0 errorsbb testwithCOPILOT_E2E_TESTS=true— 0 failures, 1 errortest-e2e-blob-attachmenttiming out after 30sagainst the real Copilot CLI. Reproduced identically on
origin/main(i.e. pre-existing flake unrelated to these changes).
./run-all-examples.sh— all examples succeedbb validate-docs— 13 files, 0 warningsMulti-model code review
Reviewers: Claude Opus 4.7 + GPT-5.5 (both ran via the
code-reviewsubagent).
::session.shutdown-datastill requires:total-premium-requestsafter schema relaxed itcwd→workingDirectoryin JS; Clojure still uses:cwdpreMcpToolCall; tracked with the broader PR #1357 deferral (see CHANGELOG)Tracked-but-not-ported
naming churn (
cwd → workingDirectory,onExitPlanMode → onExitPlanModeRequest,disableResume → suppressResumeEvent,getMessages → getEvents,InputOptions → UiInputOptions,maxInputTokens → maxPromptTokens, removal ofautoStart/autoRestart). All breaking; deferred to a separate PR withdeprecation aliases. Clojure's existing
:max-input-tokens→maxPromptTokenswire shim already matches the new world.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com