Skip to content

Commit d4ff40c

Browse files
committed
refactor(v2): remove redundant agent protocol
1 parent a9e16e0 commit d4ff40c

6 files changed

Lines changed: 7 additions & 20 deletions

File tree

docs/experimental-v2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ router = AgentProtocolRouter(
5454
await router.run()
5555
```
5656

57-
The factories create a fresh agent for each connection, so connection state is
58-
never shared accidentally.
57+
The selected factory is called once per connection. Return a fresh agent from
58+
each call to avoid sharing connection state.
5959

6060
Extension method names are explicit and must include the protocol-required `_`
6161
prefix:

src/acp/experimental/negotiation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
]
2525

2626
V1AgentFactory = Callable[[V1AgentSideConnection], V1Agent]
27-
V2AgentFactory = Callable[[V2AgentSideConnection], v2.Agent]
27+
V2AgentFactory = Callable[[V2AgentSideConnection], object]
2828

2929

3030
def _dump(model: BaseModel) -> dict[str, Any]:

src/acp/experimental/v2/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
from . import schema
44
from .agent import AgentSideConnection, run_agent
55
from .client import ClientSideConnection, connect_to_agent
6-
from .interfaces import Agent
76
from .meta import PROTOCOL_VERSION
87

98
__all__ = [
109
"PROTOCOL_VERSION",
11-
"Agent",
1210
"AgentSideConnection",
1311
"ClientSideConnection",
1412
"connect_to_agent",

src/acp/experimental/v2/agent.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
CreateElicitationResponse,
2020
)
2121
from ._router import MethodRouter
22-
from .interfaces import Agent
2322
from .meta import CLIENT_METHODS
2423

2524
__all__ = ["AgentSideConnection", "run_agent"]
@@ -30,7 +29,7 @@ def _dump(model: BaseModel) -> dict[str, Any]:
3029

3130

3231
class _AgentRouter:
33-
def __init__(self, agent: Agent, state: InitializationState) -> None:
32+
def __init__(self, agent: object, state: InitializationState) -> None:
3433
self._router = MethodRouter(agent, AGENT_REQUESTS, AGENT_NOTIFICATIONS)
3534
self._state = state
3635

@@ -56,7 +55,7 @@ class AgentSideConnection:
5655

5756
def __init__(
5857
self,
59-
agent: Agent,
58+
agent: object,
6059
input_stream: Any,
6160
output_stream: Any = None,
6261
*,
@@ -78,7 +77,7 @@ def __init__(
7877
@classmethod
7978
def _attach(
8079
cls,
81-
agent_factory: Callable[[AgentSideConnection], Agent],
80+
agent_factory: Callable[[AgentSideConnection], object],
8281
connection: Connection,
8382
) -> tuple[AgentSideConnection, _AgentRouter]:
8483
self = cls.__new__(cls)
@@ -161,7 +160,7 @@ def _extension_method(method: str) -> str:
161160

162161

163162
async def run_agent(
164-
agent: Agent,
163+
agent: object,
165164
input_stream: Any = None,
166165
output_stream: Any = None,
167166
*,

src/acp/experimental/v2/interfaces.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/test_v2_runtime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ def test_v2_public_entry_point_is_explicit() -> None:
231231
assert exported["PROTOCOL_VERSION"] == 2
232232
assert exported["schema"] is v2.schema
233233
assert set(exported) == {
234-
"Agent",
235234
"AgentSideConnection",
236235
"ClientSideConnection",
237236
"PROTOCOL_VERSION",

0 commit comments

Comments
 (0)