Skip to content

Commit 182ec0f

Browse files
committed
fix: preserve shell exit code with stderr output
1 parent de0cfe0 commit 182ec0f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/google/adk/tools/skill_toolset.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,13 @@ async def execute_script_async(
564564
stdout = parsed.get("stdout", "")
565565
stderr = parsed.get("stderr", "")
566566
rc = parsed.get("returncode", 0)
567-
if rc != 0 and not stderr:
568-
stderr = f"Exit code {rc}"
567+
if rc != 0:
568+
exit_code_message = f"Exit code {rc}"
569+
stderr = (
570+
f"{stderr.rstrip()}\n{exit_code_message}"
571+
if stderr
572+
else exit_code_message
573+
)
569574
except (json.JSONDecodeError, ValueError):
570575
pass
571576

@@ -745,6 +750,7 @@ def _build_wrapper_code(
745750
" _r = subprocess.run(",
746751
f" {arr!r},",
747752
" capture_output=True, text=True,",
753+
# Keep shell output decoding independent from the host locale.
748754
" encoding='utf-8', errors='replace',",
749755
f" timeout={timeout!r}, cwd=td,",
750756
" )",

0 commit comments

Comments
 (0)