Skip to content

Add optional header field to ask_user across all SDKs#1624

Closed
patniko wants to merge 1 commit into
mainfrom
ask-user-header-field
Closed

Add optional header field to ask_user across all SDKs#1624
patniko wants to merge 1 commit into
mainfrom
ask-user-header-field

Conversation

@patniko

@patniko patniko commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What & why

Companion to github/copilot-agent-runtime#10078, which adds a short, model-populated header to the ask_user tool — surfaced on the user_input.requested event and the userInput.request RPC, mirroring Anthropic's AskUserQuestion.header. Hosts can render it as a dialog title instead of synthesizing one from the question.

This PR adds header to the hand-written userInput.request handler request type that integrators implement, in every language, plus README docs:

Language Hand-written handler type README
Node src/types.ts UserInputRequest, src/client.ts
Python copilot/session.py UserInputRequest TypedDict + handler
Go types.go (public + wire structs), client.go mapping
.NET Types.cs UserInputRequest, Client.cs RPC param
Rust handler.rs trait, session.rs dispatch
Java rpc/UserInputRequest (+getHeader/setHeader), RpcHandlerDispatcher

The field is optional everywhere; existing callers are unaffected.

Generated event type — intentionally not touched here

The generated UserInputRequestedData (the user_input.requested event payload) is produced by codegen from the @github/copilot schema. It is left untouched so the Codegen Check stays green. It will gain header automatically once:

  1. The runtime change ships and @github/copilot is bumped to that version.
  2. npm run generate (ts/csharp/python/go/rust) and cd java && mvn generate-sources -Pcodegen are run.
  3. E2E snapshots under test/snapshots/ask_user/ are re-recorded (the CLI doesn't emit header yet).

⚠️ Breaking (Rust only)

UserInputHandler::handle gains a header: Option<String> parameter (positional trait method). All in-repo implementors (example + tests) are updated.

Verification

Node typecheck ✅ · Go go build ./... ✅ · .NET dotnet build ✅ · Rust cargo build + cargo test --no-run ✅ · Python py_compile ✅. Java not compiled (no JDK in this environment); edits follow the existing record/fluent-setter/dispatcher patterns.

@github-actions

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>
@patniko patniko force-pushed the ask-user-header-field branch from 5e3629c to a07dbba Compare June 10, 2026 16:50
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review

The code changes across all six SDKs look well-aligned — all SDKs correctly add the optional header field to the UserInputRequest type and pass it through to the handler. ✅

Two minor README documentation gaps were flagged with inline comments:

SDK Code README
Node.js
Python
Go
.NET ⚠️ dotnet/README.md line 807 lists other fields but is missing // request.Header - ...
Rust
Java ⚠️ java/README.md has no UserInputRequest/ask_user section at all

The PR description already calls these out with — just confirming the specific locations. The .NET fix is a one-liner. The Java gap is pre-existing and potentially its own follow-up.

Everything else (type definitions, wire struct mappings, handler dispatch, nullability/optionality treatment) is consistent across all languages.

Generated by SDK Consistency Review Agent for issue #1624 · sonnet46 1.3M ·

@github-actions github-actions Bot 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.

Generated by SDK Consistency Review Agent for issue #1624 · sonnet46 1.3M

Comment thread dotnet/src/Types.cs
/// Optional short title summarizing the question, shown as the dialog header/title in some UIs.
/// </summary>
[JsonPropertyName("header")]
public string? Header { get; set; }

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.

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;

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.

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();

@patniko patniko closed this Jun 10, 2026
@patniko patniko deleted the ask-user-header-field branch June 10, 2026 16:59
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.

1 participant