Problem statement
Taking from the quick start example:
importasyncioimportsysfrompathlibimportPathfromacpimportspawn_agent_process, text_blockfromacp.interfacesimportClientfromacp.schemaimportInitializeRequest, NewSessionRequest, PromptRequest, SessionNotificationclassSimpleClient(Client):
asyncdefrequestPermission(self, params): # pragma: no cover - minimal stubreturn {"outcome": {"outcome": "cancelled"}}
asyncdefsessionUpdate(self, params: SessionNotification) ->None:
print("update:", params.sessionId, params.update)
asyncdefmain() ->None:
script=Path("examples/echo_agent.py")
asyncwithspawn_agent_process(lambda_agent: SimpleClient(), sys.executable, str(script)) as (conn, _proc):
awaitconn.initialize(InitializeRequest(protocolVersion=1))
session=awaitconn.newSession(NewSessionRequest(cwd=str(script.parent), mcpServers=[]))
awaitconn.prompt(
PromptRequest(
sessionId=session.sessionId,
prompt=[text_block("Hello from spawn!")],
)
)
asyncio.run(main())connection.initialize takes a single parameter with a set fields defined, and users have to import that InitializeRequest to construct it. Same as connection.newSession() method.
It can be easily changed to the following API style:
connection.initialize(protocol_version=1)
(snake_case is also preferred)
Proposed solution
While this is a breaking change, we can add a compatibility layer on such methods, something like below:
@compat_params(InitializeRequest)asyncdefinitialize(self, protocol_version: int) ->InitializeResponse:
returnawaitrequest_model(
self._conn,
AGENT_METHODS["initialize"],
InitializeRequest(protocolVersion=protocol_version),
InitializeResponse,
)
Alternatives considered
If it's not easy to do over the codebase, in the worst case, we can add a acp._next package with the new APIs, and export all members in acp/__init__.py with proper deprecation warnings.
Additional context
No response
Can you help build it?
Problem statement
Taking from the quick start example:
connection.initializetakes a single parameter with a set fields defined, and users have to import thatInitializeRequestto construct it. Same asconnection.newSession()method.It can be easily changed to the following API style:
(snake_case is also preferred)
Proposed solution
While this is a breaking change, we can add a compatibility layer on such methods, something like below:
Alternatives considered
If it's not easy to do over the codebase, in the worst case, we can add a
acp._nextpackage with the new APIs, and export all members inacp/__init__.pywith proper deprecation warnings.Additional context
No response
Can you help build it?