Skip to content

bug: on_connect arg is AgentSideConnection at runtime while methods and params are different than Client #49

@Nemtecl

Description

@Nemtecl

Summary

Type Client and AgentSideConnection are not the same, while on_connect params is a Client, it is a AgentSideConnection at runtime (

conn = AgentSideConnection(
)

There is a cast forced here

https://github.com/agentclientprotocol/python-sdk/blob/main/src/acp/agent/connection.py#L64

When using Client, there are method such as create_terminal that does not return the same values nor property

I really like the move to snake case, but I think it added a lot of breaking changes, especially to load the Agent. Shouldn't this release have been a major ?

Reproduction steps

class ExampleAgent(Agent)
  #...

  @override
    def on_connect(self, conn: Client) -> None:
        self.client = conn
        # ^ this is AgentSideConnection at runtime
    terminal_handle = await client.create_terminal(...)
    print(terminal_handle.terminal_id)
    # ^ this break because terminal_handle is not `CreateTerminalResponse` with `terminal_id` but `TerminalHandle` with `id`

Also, having Client and AgentSideConnection being different type with no inheritence + AgenceSideConnection being now final make the test harder to write, especially when you need to stub AgentSideConnection

Expected result

Client and AgentSideConnection should have similar property so that the types expected at runtime are the same. I'd expect on_connect to receive an AgentSideConnection instead of Client which is a protocol

Actual result

class ExampleAgent(Agent)
  #...

  @override
    def on_connect(self, conn: Client) -> None:
        self.client = conn
        # ^ this is AgentSideConnection at runtime
    terminal_handle = await client.create_terminal(...)
    print(terminal_handle.terminal_id)
    # ^ this break because terminal_handle is not `CreateTerminalResponse` with `terminal_id` but `TerminalHandle` with `id`

Versions / environment

sdk 0.7.0, Python 3.12, macOS 15.7.3

Quick fix for now is to force cast Client into AgentSideConnection

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions