Add optional header field to ask_user across all SDKs#1624
Conversation
This comment has been minimized.
This comment has been minimized.
Companion to the runtime change (github/copilot-agent-runtime#10078), which adds a short, model-populated `header` to the `ask_user` tool / `user_input.requested` event / `userInput.request` RPC — mirroring Anthropic's `AskUserQuestion.header`. Hosts can render it as a dialog title instead of synthesizing one from the question. This adds `header` to the hand-written `userInput.request` handler request type that integrators implement, in every language, plus README docs: - Node: types.ts (UserInputRequest) + client.ts handler, README - Python: session.py (UserInputRequest TypedDict + handler), README - Go: types.go (public + wire structs) + client.go mapping, README - .NET: Types.cs (UserInputRequest) + Client.cs RPC param - Rust: handler.rs trait + session.rs dispatch + example/tests, README - Java: rpc/UserInputRequest (+getHeader/setHeader) + RpcHandlerDispatcher param mapping The field is optional everywhere; existing callers are unaffected. BREAKING (Rust only): `UserInputHandler::handle` gains a `header: Option<String>` parameter. All in-repo implementors are updated. The generated `UserInputRequestedData` event type is intentionally NOT touched here: it is produced by codegen from the `@github/copilot` schema and will gain `header` automatically once the dep is bumped to the version carrying the runtime change and `npm run generate` / `mvn generate-sources -Pcodegen` are run. (E2E snapshots under test/snapshots/ask_user/ likewise re-recorded then.) Verified: Node typecheck, Go build, .NET build, Rust build + test-compile, Python py_compile. Java not compiled (no JDK in env); edits follow existing patterns. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5e3629c to
a07dbba
Compare
Cross-SDK Consistency ReviewThe code changes across all six SDKs look well-aligned — all SDKs correctly add the optional Two minor README documentation gaps were flagged with inline comments:
The PR description already calls these out with Everything else (type definitions, wire struct mappings, handler dispatch, nullability/optionality treatment) is consistent across all languages.
|
There was a problem hiding this comment.
Generated by SDK Consistency Review Agent for issue #1624 · sonnet46 1.3M
| /// Optional short title summarizing the question, shown as the dialog header/title in some UIs. | ||
| /// </summary> | ||
| [JsonPropertyName("header")] | ||
| public string? Header { get; set; } |
There was a problem hiding this comment.
The .NET code is updated here, but dotnet/README.md line 807 still documents only question, choices, and allowFreeform in the OnUserInputRequest example. All other SDK READMEs (Node, Python, Go, Rust) were updated to mention header — .NET is the odd one out.
Suggested addition at dotnet/README.md line 808 (after // request.Question - ...):
// request.Header - Optional short title summarizing the question (suitable as a dialog title)| private String question; | ||
|
|
||
| @JsonProperty("header") | ||
| private String header; |
There was a problem hiding this comment.
The Java code correctly gains header, but the Java README (java/README.md) has no UserInputRequest / ask_user documentation section at all — unlike every other SDK README. This pre-existing gap is now more visible since the other READMEs all show the new field.
Consider adding a "User Input Requests" section to java/README.md (modelled after the Node/Python/Go/.NET equivalents) that documents the onUserInputRequest handler, including the new header field. For example:
var session = client.createSession(new SessionConfig()
.setModel("gpt-5")
.setOnUserInputRequest((request, invocation) -> {
// request.getQuestion() - The question to ask
// request.getHeader() - Optional short title suitable as a dialog title
// request.getChoices() - Optional list of choices for multiple choice
// request.isAllowFreeform() - Whether freeform input is allowed (default: true)
return CompletableFuture.completedFuture(
new UserInputResponse().setAnswer("User's answer here").setWasFreeform(true)
);
})).get();
What & why
Companion to github/copilot-agent-runtime#10078, which adds a short, model-populated
headerto theask_usertool — surfaced on theuser_input.requestedevent and theuserInput.requestRPC, mirroring Anthropic'sAskUserQuestion.header. Hosts can render it as a dialog title instead of synthesizing one from the question.This PR adds
headerto the hand-writtenuserInput.requesthandler request type that integrators implement, in every language, plus README docs:src/types.tsUserInputRequest,src/client.tscopilot/session.pyUserInputRequestTypedDict + handlertypes.go(public + wire structs),client.gomappingTypes.csUserInputRequest,Client.csRPC paramhandler.rstrait,session.rsdispatchrpc/UserInputRequest(+getHeader/setHeader),RpcHandlerDispatcherThe field is optional everywhere; existing callers are unaffected.
Generated event type — intentionally not touched here
The generated
UserInputRequestedData(theuser_input.requestedevent payload) is produced by codegen from the@github/copilotschema. It is left untouched so the Codegen Check stays green. It will gainheaderautomatically once:@github/copilotis bumped to that version.npm run generate(ts/csharp/python/go/rust) andcd java && mvn generate-sources -Pcodegenare run.test/snapshots/ask_user/are re-recorded (the CLI doesn't emitheaderyet).UserInputHandler::handlegains aheader: Option<String>parameter (positional trait method). All in-repo implementors (example + tests) are updated.Verification
Node typecheck ✅ · Go
go build ./...✅ · .NETdotnet build✅ · Rustcargo build+cargo test --no-run✅ · Pythonpy_compile✅. Java not compiled (no JDK in this environment); edits follow the existing record/fluent-setter/dispatcher patterns.