fix: align create_terminal return type with runtime handle#50
Conversation
Signed-off-by: Chojan Shang <psiace@apache.org>
There was a problem hiding this comment.
Pull request overview
This PR addresses a type mismatch between the Client.create_terminal protocol signature and its runtime behavior. The fix provides a temporary solution by widening the return type and adding a backward-compatible property alias.
Key Changes:
- Added a
terminal_idproperty toTerminalHandlethat aliases the existingidattribute, ensuring naming consistency withCreateTerminalResponse.terminal_id - Widened the
Client.create_terminalreturn type fromCreateTerminalResponsetoCreateTerminalResponse | TerminalHandleto accommodate both test implementations (which return the response directly) and runtime behavior (which wraps responses inTerminalHandle) - Added a regression test validating that agents can call
create_terminalthroughon_connectconnections and accessterminal_idon the result
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/acp/terminal.py | Adds terminal_id property as an alias to the id attribute for API consistency |
| src/acp/interfaces.py | Updates Client.create_terminal return type to union of CreateTerminalResponse | TerminalHandle |
| tests/test_rpc.py | Adds regression test validating on_connect + create_terminal interaction and terminal_id accessibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| output_byte_limit: int | None = None, | ||
| **kwargs: Any, | ||
| ) -> CreateTerminalResponse: ... | ||
| ) -> CreateTerminalResponse | TerminalHandle: ... |
There was a problem hiding this comment.
The union return type CreateTerminalResponse | TerminalHandle creates ambiguity for API consumers. Callers cannot determine at compile-time which type will be returned, requiring runtime type checking. Consider documenting which implementations return which type, or ideally standardizing all implementations to return the same type (TerminalHandle) for consistency with the runtime behavior shown in agent/connection.py.
| ) -> CreateTerminalResponse | TerminalHandle: ... | |
| ) -> TerminalHandle: ... |
Signed-off-by: Chojan Shang <psiace@apache.org>
Summary
Temporary fix:
match runtime.
Related issues
Related to #49
Testing
Docs & screenshots
Checklist
feat:,fix:).make gen-all) are called out if applicable.