Skip to content

Add usingListModels() fluent method to Client#33

Merged
kawax merged 2 commits intosdk-sync/2026-03-09-98a9c4c1d5830df5from
copilot/sub-pr-32
Mar 9, 2026
Merged

Add usingListModels() fluent method to Client#33
kawax merged 2 commits intosdk-sync/2026-03-09-98a9c4c1d5830df5from
copilot/sub-pr-32

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

Adds a fluent usingListModels(?callable $callback = null): static method to Client and the CopilotClient contract. Since the client instance can be re-initialized between calls, the constructor on_list_models option is fragile — setting the handler inline immediately before listModels() is the safer pattern.

Changes

  • src/Client.phpusingListModels() sets $onListModels and returns $this; updated listModels() docblock to reference it
  • src/Contracts/CopilotClient.php — added usingListModels() to the interface
  • docs/jp/custom-providers.md — promotes usingListModels() as the recommended approach; retains constructor option as alternative

Usage

$models = Copilot::client()->usingListModels(fn() => [
    ['id' => 'my-model', 'name' => 'My Model', 'version' => '1.0'],
])->listModels();

Pass null to clear the handler and fall back to querying the CLI server.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: kawax <1502086+kawax@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix usingListModels implementation and update custom-providers.md Add usingListModels() fluent method to Client Mar 9, 2026
Copilot finished work on behalf of kawax March 9, 2026 09:12
@kawax kawax marked this pull request as ready for review March 9, 2026 09:15
@kawax kawax merged commit 67cf3b7 into sdk-sync/2026-03-09-98a9c4c1d5830df5 Mar 9, 2026
5 checks passed
@kawax kawax deleted the copilot/sub-pr-32 branch March 9, 2026 09:15
kawax added a commit that referenced this pull request Mar 9, 2026
…s handler (#32)

* Sync with copilot-sdk: add agent param and onListModels handler

- Add `agent` property to SessionConfig and ResumeSessionConfig for
  pre-selecting a custom agent when a session starts or resumes
- Add `on_list_models` callable option to Client for BYOK mode;
  when set, listModels() calls the handler instead of querying CLI
- Pass `agent` in session.create and session.resume RPC requests
- Update submodule pointer to e478657 (396e8b3..e478657)
- Update docs/jp/session-config.md and docs/jp/custom-providers.md

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

* Add `usingListModels()` fluent method to Client (#33)

* Initial plan

* Add usingListModels() fluent method to Client and update docs

Co-authored-by: kawax <1502086+kawax@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kawax <1502086+kawax@users.noreply.github.com>

* Remove `on_list_models` constructor option from Client; keep only `usingListModels()` (#34)

* Initial plan

* Remove on_list_models constructor option, keep only usingListModels

Co-authored-by: kawax <1502086+kawax@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kawax <1502086+kawax@users.noreply.github.com>

* Add tests for `agent` parameter and `usingListModels()` (#35)

* Initial plan

* Add tests for agent parameter and usingListModels

Co-authored-by: kawax <1502086+kawax@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kawax <1502086+kawax@users.noreply.github.com>

---------

Co-authored-by: GitHub Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kawax <1502086+kawax@users.noreply.github.com>
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.

2 participants