Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/agents/run_internal/tool_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ def coerce_shell_call(tool_call: Any) -> ShellCallData:
raise ModelBehaviorError("Shell call is missing an action payload.")

commands_value = get_mapping_or_attr(action_payload, "commands")
if isinstance(commands_value, (str, bytes, bytearray)):
raise ModelBehaviorError(
"Shell call action commands must be a list of strings, not a single string-like value."
)
if not isinstance(commands_value, Sequence):
raise ModelBehaviorError("Shell call action is missing commands.")
commands: list[str] = []
Expand Down
7 changes: 7 additions & 0 deletions tests/test_shell_call_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def test_coerce_shell_call_requires_commands() -> None:
run_loop.coerce_shell_call(tool_call)


def test_coerce_shell_call_rejects_string_like_commands() -> None:
for commands in ("echo hi", b"echo hi", bytearray(b"echo hi")):
tool_call = {"call_id": "shell-3", "action": {"commands": commands}}
with pytest.raises(ModelBehaviorError, match="list of strings"):
run_loop.coerce_shell_call(tool_call)


def test_normalize_shell_output_handles_timeout() -> None:
entry = {
"stdout": "",
Expand Down