Skip to content

Port upstream SDK changes: auth options, reasoning effort, user input, handlers, and hooks.#7

Merged
brunoborges merged 15 commits intomainfrom
merge-upstream-20260201
Feb 2, 2026
Merged

Port upstream SDK changes: auth options, reasoning effort, user input, handlers, and hooks.#7
brunoborges merged 15 commits intomainfrom
merge-upstream-20260201

Conversation

@brunoborges
Copy link
Member

@brunoborges brunoborges commented Feb 1, 2026

Features ported from upstream copilot-sdk (87ff5510..a552ae4):

Feature Description
Authentication Options Added githubToken and useLoggedInUser to CopilotClientOptions for BYOK scenarios
Reasoning Effort Added reasoningEffort field to session configs and model info for models that support it
User Input Handler Added UserInputHandler and related types for handling agent ask_user tool calls
Hooks System Added pre/post tool-use hooks for intercepting and modifying tool execution
Working Directory Added workingDirectory to session configs
Disable Resume Added disableResume option to ResumeSessionConfig
Models Caching Cache listModels() results to prevent rate limiting
  1. Authentication options (PR #237, #2fe7352):

    • Add githubToken and useLoggedInUser to CopilotClientOptions
    • Pass auth flags to CLI process on startup
    • Validate auth options with external server (CliUrl)
  2. Reasoning effort support (PR #302, #c39a129):

    • Add reasoningEffort field to SessionConfig/ResumeSessionConfig
    • Add reasoningEffort boolean to ModelSupports
    • Add supportedReasoningEfforts and defaultReasoningEffort to ModelInfo
  3. User input handler (PR #269, #2fa6a92):

    • Add UserInputRequest, UserInputResponse, UserInputHandler, UserInputInvocation
    • Add onUserInputRequest to SessionConfig and ResumeSessionConfig
    • Handle userInput.request RPC method in CopilotClient
    • Add registerUserInputHandler and handleUserInputRequest to CopilotSession
  4. Hooks system (PR #269, #2fa6a92):

    • Add PreToolUseHookInput/Output, PostToolUseHookInput/Output
    • Add PreToolUseHandler, PostToolUseHandler functional interfaces
    • Add SessionHooks and HookInvocation classes
    • Handle hooks.invoke RPC method in CopilotClient
    • Add registerHooks and handleHooksInvoke to CopilotSession
  5. Session config enhancements:

    • Add workingDirectory to SessionConfig and ResumeSessionConfig
    • Add disableResume to ResumeSessionConfig
  6. Models caching (PR #300, #a552ae4):

    • Cache listModels() results to prevent rate limiting
    • Clear cache on disconnect

Changes Ported from Upstream (commits 87ff5510..a552ae4)

… handlers, hooks

Features ported from upstream copilot-sdk (87ff5510..a552ae4):

1. Authentication options (PR #237, #2fe7352):
   - Add githubToken and useLoggedInUser to CopilotClientOptions
   - Pass auth flags to CLI process on startup
   - Validate auth options with external server (CliUrl)

2. Reasoning effort support (PR #302, #c39a129):
   - Add reasoningEffort field to SessionConfig/ResumeSessionConfig
   - Add reasoningEffort boolean to ModelSupports
   - Add supportedReasoningEfforts and defaultReasoningEffort to ModelInfo

3. User input handler (PR #269, #2fa6a92):
   - Add UserInputRequest, UserInputResponse, UserInputHandler, UserInputInvocation
   - Add onUserInputRequest to SessionConfig and ResumeSessionConfig
   - Handle userInput.request RPC method in CopilotClient
   - Add registerUserInputHandler and handleUserInputRequest to CopilotSession

4. Hooks system (PR #269, #2fa6a92):
   - Add PreToolUseHookInput/Output, PostToolUseHookInput/Output
   - Add PreToolUseHandler, PostToolUseHandler functional interfaces
   - Add SessionHooks and HookInvocation classes
   - Handle hooks.invoke RPC method in CopilotClient
   - Add registerHooks and handleHooksInvoke to CopilotSession

5. Session config enhancements:
   - Add workingDirectory to SessionConfig and ResumeSessionConfig
   - Add disableResume to ResumeSessionConfig

6. Models caching (PR #300, #a552ae4):
   - Cache listModels() results to prevent rate limiting
   - Clear cache on disconnect
…tests

- Add AskUserTest for user input handler functionality (disabled pending harness update)
- Add HooksTest for pre/post tool-use hooks (disabled pending harness update)
- Add auth options tests to CopilotClientTest:
  - testGithubTokenOptionAccepted
  - testUseLoggedInUserDefaultsToNull
  - testExplicitUseLoggedInUserFalse
  - testExplicitUseLoggedInUserTrueWithGithubToken
  - testGithubTokenWithCliUrlThrows
  - testUseLoggedInUserWithCliUrlThrows

Note: AskUserTest and HooksTest are disabled because they require test harness
updates with support for the new RPC methods (ask_user, hooks). These tests
will be enabled once the harness is updated (see upstream PR #269).
Add Step 7.5 with detailed instructions for:
- Checking for new/updated tests in upstream
- Porting test cases to Java following existing patterns
- Test file mapping table
- Handling test harness compatibility issues
- Unit tests vs E2E tests guidance

Update checklist to include:
- New/updated tests ported from upstream
- Tests marked @disabled if harness doesn't support new features
…able

These tests require CLI version 0.0.400+ which includes support for the
ask_user tool and hooks system. The test harness uses a separate
XDG_CONFIG_HOME which causes the CLI to download an older runtime
version (0.0.394) that doesn't support these features.

The tests are properly implemented but disabled with @disabled annotation
until the CLI runtime version issue is resolved.
…tory for test resources; update maven-antrun-plugin version and add necessary dependencies
…onse test due to upstream snapshot format mismatch
@brunoborges brunoborges merged commit 28336b2 into main Feb 2, 2026
2 checks passed
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