-
Notifications
You must be signed in to change notification settings - Fork 798
fix(acp): parse shell command for terminal/create to fix acpx compatibility #1688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||
| import asyncio | ||||||||||||
| from contextlib import suppress | ||||||||||||
| import shlex | ||||||||||||
|
|
||||||||||||
| import acp | ||||||||||||
| from kaos import get_current_kaos | ||||||||||||
|
|
@@ -88,8 +89,13 @@ async def __call__(self, params: ShellParams) -> ToolReturnValue: | |||||||||||
| timed_out = False | ||||||||||||
|
|
||||||||||||
| try: | ||||||||||||
| # Parse command string into command and args for ACP | ||||||||||||
| parts = shlex.split(params.command) | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 shlex.split() raises unhandled ValueError on malformed quotes in command
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using Useful? React with 👍 / 👎. |
||||||||||||
| cmd = parts[0] if parts else "" | ||||||||||||
| args = parts[1:] if len(parts) > 1 else [] | ||||||||||||
|
Comment on lines
+93
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 shlex.split() breaks shell compound commands (pipes, redirects, &&, ||, etc.) The LLM generates commands intended for shell interpretation (the Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||
| resp = await self._acp_conn.create_terminal( | ||||||||||||
|
Comment on lines
+92
to
96
|
||||||||||||
| command=params.command, | ||||||||||||
| command=cmd, | ||||||||||||
|
Comment on lines
+93
to
+97
|
||||||||||||
| args=args, | ||||||||||||
| session_id=self._acp_session_id, | ||||||||||||
| output_byte_limit=builder.max_chars, | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shlex.split()can raiseValueError(e.g., unmatched quotes). Right now that exception will bubble up and likely surface as a generic ACP "Internal error". Consider catchingValueErrorhere and returning a user-facing tool error like "Invalid command" (including the parse error in debug logs).