Skip to content

[1.0.94/v1.0.18]New version python SDK could not work with BYOK #2826

Agent suggestions

Public preview

Description

@zeerd

Works fine:

"copilot_version": "1.0.92",
"copilot_sdk_version": "v1.0.18"

Timeout after upgrade to:

"copilot_version": "1.0.94",
"copilot_sdk_version": "v1.0.18"

Code:

    async with CopilotClient() as client:
        async with await client.create_session(
            on_permission_request=PermissionHandler.approve_all,
            model="abc",
            provider={
                "type": "openai",
                "base_url": "http://host.docker.internal:1234/v1",
                # "api_key": os.environ.get("MY_API_KEY", "123"),
            },
            system_message={
                "mode": "replace", "content": "You are a helpful AI assistant."
            }
        ) as session:
            def on_event(event):
                print(event)
                match event.data:
                    case AssistantMessageData() as data:
                        print(data.content)
                    case SessionIdleData():
                        print('Done')

            session.on(on_event)

            print("Hello!")
            await session.send_and_wait("Hello!")
            await session.disconnect()
            await client.stop()

Log:

SessionEvent(data=SessionStartData(copilot_version='1.0.94', producer='copilot-agent', session_id='ec13e13d-af1c-49bd-a1af-0b4af1ee27ea', start_time=datetime.datetime(2026, 10, 9, 4, 9, 59, 657000, tzinfo=tzutc()), version=1, already_in_use=False, auto_tier=None, auto_tier_managed=None, context=WorkingDirectoryContext(cwd='/app', base_commit=None, branch='xauto_hub/main', git_root='/app', head_commit='7055bb4619217c5488e4b0a03768fdef58614375', host_type=None, pending_git_context=None, repository=None, repository_host=None), context_tier=None, context_tier_managed=None, detached_from_spawning_parent_session_id=None, github_mcp_tool_config=None, provider_id=None, reasoning_effort=None, reasoning_effort_managed=None, reasoning_effort_model=None, reasoning_summary=None, remote_steerable=False, selected_model='abc', session_limits=None, verbosity=None), id=UUID('60bedb05-0b11-45c1-b997-577117d09a5e'), timestamp=datetime.datetime(2026, 10, 9, 4, 9, 59, 675000, tzinfo=tzutc()), type=<SessionEventType.SESSION_START: 'session.start'>, agent_id=None, ephemeral=None, parent_id=None, raw_type=None)
SessionEvent(data=SessionManagedSettingsResolvedData(bypass_permissions_disabled=False, device_managed=False, fail_closed=False, managed_keys=[], server_managed=False, source=<ManagedSettingsResolvedSource.NONE: 'none'>, client_managed=False, permissions_allow_intersected=None, policy_helper_managed=False, sandbox_enabled_by_undetermined_policy=False, settings=None), id=UUID('08dd458a-573c-417c-8619-762e47f22fbe'), timestamp=datetime.datetime(2026, 10, 9, 4, 9, 59, 676000, tzinfo=tzutc()), type=<SessionEventType.SESSION_MANAGED_SETTINGS_RESOLVED: 'session.managed_settings_resolved'>, agent_id=None, ephemeral=True, parent_id=UUID('60bedb05-0b11-45c1-b997-577117d09a5e'), raw_type=None)
SessionEvent(data=PendingMessagesModifiedData(), id=UUID('e142416d-5364-480e-93c3-0497451c0927'), timestamp=datetime.datetime(2026, 10, 9, 4, 9, 59, 728000, tzinfo=tzutc()), type=<SessionEventType.PENDING_MESSAGES_MODIFIED: 'pending_messages.modified'>, agent_id=None, ephemeral=True, parent_id=UUID('60bedb05-0b11-45c1-b997-577117d09a5e'), raw_type=None)
CopilotSession.send_and_wait failed
SessionEvent(data=SessionShutdownData(code_changes=ShutdownCodeChanges(files_modified=[], lines_added=0, lines_removed=0), model_metrics={}, session_start_time=1791518999657, shutdown_type=<ShutdownType.ROUTINE: 'routine'>, total_api_duration=datetime.timedelta(0), _accounting_snapshot=None, agent_metrics=None, conversation_tokens=0, current_model=None, current_tokens=3, error_reason=None, events_file_size_bytes=None, provider_model_metrics=None, system_tokens=0, token_details=None, tool_definitions_tokens=0, total_nano_aiu=0.0, _total_premium_requests=0.0, usage_accounting_watermarks=None), id=UUID('8f7f5d4e-ad43-4045-b814-cc4adad5c3ad'), timestamp=datetime.datetime(2026, 10, 9, 4, 10, 59, 793000, tzinfo=tzutc()), type=<SessionEventType.SESSION_SHUTDOWN: 'session.shutdown'>, agent_id=None, ephemeral=None, parent_id=UUID('60bedb05-0b11-45c1-b997-577117d09a5e'), raw_type=None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/copilot/session.py", line 2239, in send_and_wait
    await asyncio.wait_for(idle_event.wait(), timeout=timeout)
  File "/usr/local/lib/python3.13/asyncio/tasks.py", line 506, in wait_for
    async with timeouts.timeout(timeout):
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/timeouts.py", line 116, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/Agent/debugs/debug_copilot_byok.py", line 52, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/app/Agent/debugs/debug_copilot_byok.py", line 48, in main
    await session.send_and_wait("Hello!")
  File "/usr/local/lib/python3.13/site-packages/copilot/session.py", line 2269, in send_and_wait
    raise TimeoutError(f"Timeout after {timeout}s waiting for session.idle")
TimeoutError: Timeout after 60.0s waiting for session.idle

Activity

  1. github-actions commented on Oct 9, 2026

    @github-actions
    Contributor

    Thanks for the report. I could not reproduce this because it needs your local OpenAI-compatible server, so this is based on reading the code.

    What I checked

    • python/copilot/client.py (_convert_provider_to_wire_format): your type, base_url and model are sent to the runtime correctly. base_url becomes baseUrl, and api_key is only sent if you set it.
    • python/copilot/session.py (send_and_wait): the TimeoutError is the SDK's default 60s wait for session.idle. The SDK never got an error event, and none appeared in your log. Your log shows session.start with selected_model='abc', then pending_messages_modified, then nothing until the shutdown after 60s.

    What this suggests
    The Python SDK's provider handling looks fine. The turn seems to stall inside the Copilot CLI runtime (1.0.94) while it handles the BYOK provider. That could be a runtime change, such as stricter provider or model validation or a different request path. It could also be that the runtime can't reach (host.docker.internal/redacted) from your container. I can't tell which from the SDK side. I'm labelling this questionrather thanbug` for now.

    Things to try

    1. Check that the endpoint is reachable from inside the container, for example `curl (host.docker.internal/redacted) and look at the server logs to see whether a request arrives at all.
    2. Set api_key explicitly, even to a dummy value. Newer runtimes may expect one for type: "openai".
    3. Provide the model details for the custom model, such as wire_model, model_id, max_prompt_tokens and max_output_tokens, in the provider config.
    4. Try wire_api: "completions" or "responses" to see whether the behaviour changes.
    5. Pin the CLI to 1.0.68 while keeping SDK v1.0.18, and then the reverse (CLI 1.0.94 with SDK v1.0.5). That would show whether the regression is in the CLI or the SDK.
    6. Share the runtime logs by starting the client with log_level="debug".

    If the endpoint is reachable and a request is sent but the session still never goes idle, or the request is never sent, please reply with the debug logs and I'll reclassify this as a bug against the runtime.

    Generated by Bug Handler for #2826 · copilot · auto · 17.3 AIC · ⌖ 0.477 AIC · ⊞ 7.5K · ◷

  2. zeerd commented on Oct 9, 2026

    @zeerd
    Author

    I said, old version works fine which means the local-LLM could work with those codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions