Skip to content

session error when chat with copilot python sdk #923

@zeerd

Description

@zeerd

Anyone who can give me some suggest ... Thx.

github-copilot-sdk==0.2.0

I tried copilot v1.0.9/v1.0.10/v1.0.11
I tried to delete /root/.cache.

import asyncio
from copilot import CopilotClient
from copilot.types import PermissionHandler


async def main():
    # Create and start client
    client = CopilotClient()
    await client.start()

    # Create a session
    conf = {
        "model": "gpt-4.1",
        "on_permission_request": PermissionHandler.approve_all,
        "tools": []
    }
    session = await client.create_session(**conf)
    # await session.set_model("gpt-4.1")

    # Wait for response using session.idle event
    done = asyncio.Event()

    def on_event(event):
        print(f"Received event: {event.type.value}")
        print(f'Received data: {event.data}')
        if event.type.value == "assistant.message":
            print(event.data.content)
        elif event.type.value == "session.idle":
            done.set()

    session.on(on_event)

    # Send a message and wait for completion
    await session.send({
        "prompt": (
            "Who are you and what model you are "
            "and what kind of assistant you are?"
        )
    })
    await done.wait()

    # Clean up
    await session.disconnect()
    await client.stop()

asyncio.run(main())

Received event: session.error
Received data: Data(already_in_use=None, context=None, copilot_version=None, producer=None, reasoning_effort=None, selected_model=None, session_id=None, start_time=None, version=None, event_count=None, resume_time=None, error_type='query', message='Execution failed: TypeError: t.asString is not a function', provider_call_id=None, stack='TypeError: t.asString is not a function\n at l6 (file:///root/.cache/copilot/pkg/linux-x64/1.0.10/app.js:1040:87)\n at Lqn (file:///root/.cache/copilot/pkg/linux-x64/1.0.10/app.js:1037:90)\n at Object.asXML (file:///root/.cache/copilot/pkg/linux-x64/1.0.10/app.js:1035:14322)\n at q2r (file:///root/.cache/copilot/pkg/linux-x64/1.0.10/app.js:2363:184)\n at t.runAgenticLoop (file:///root/.cache/copilot/pkg/linux-x64/1.0.10/app.js:2521:34696)\n at async t.processQueuedItems (file:///root/.cache/copilot/pkg/linux-x64/1.0.10/app.js:2521:5712)\n at async t.processQueue (file:///root/.cache/copilot/pkg/linux-x64/1.0.10/app.js:2521:896)\n at async t.send (file:///root/.cache/copilot/pkg/linux-x64/1.0.10/app.js:2519:3497)', stat


Full log file: [session.error.log](https://github.com/user-attachments/files/26239122/session.error.log)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions