ContainerCodeExecutor reports silent nonzero exits as successful execution

未關閉
#8,210 3 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 3 天內回覆

@surajksharma07 已經在處理了。

開始於 2026年11月18日。

  • #8212 來自 @sumedh-aerram —— 未關閉

評估

這個 Issue 還沒有評估資料。

描述

tools

ContainerCodeExecutor returns exit_code=7 with empty stderr for a program such as import os; os._exit(7). Result conversion consequently emits OUTCOME_OK, and the code-execution flow resets its error retry count. Only timeout status 124 currently receives a synthesized diagnostic.

Expected: a nonzero process exit produces an execution error even without stderr, yielding OUTCOME_FAILED and consuming an error retry. Actual: silent nonzero exits appear successful. UnsafeLocalCodeExecutor already reports Code execution exited with status 7. for this input.

Offline reproduction

No Docker daemon, model, or credentials are required. Run this script with the ADK dependencies installed and PYTHONPATH=<checkout>/src:

from unittest.mock import MagicMock, patch
from google.adk.code_executors.container_code_executor import ContainerCodeExecutor
from google.adk.code_executors.code_execution_utils import CodeExecutionInput, CodeExecutionUtils

with patch('google.adk.code_executors.container_code_executor.docker') as docker:
    container = docker.from_env.return_value.containers.run.return_value
    container.exec_run.return_value = MagicMock(exit_code=0, output=(b'', b''))
    container.get_archive.return_value = ([b''], {})
    with ContainerCodeExecutor(image='offline-test') as executor:
        container.exec_run.side_effect = lambda cmd, **kw: MagicMock(
            exit_code=7 if cmd[0] == 'python3' else 0, output=(b'', b''))
        result = executor.execute_code(None, CodeExecutionInput(code='import os; os._exit(7)'))
        part = CodeExecutionUtils.build_code_execution_result_part(result)
        print(result.exit_code, repr(result.stderr), part.code_execution_result.outcome.value)

Before fix: 7 '' OUTCOME_OK.

After fix: 7 'Code execution exited with status 7.' OUTCOME_FAILED.

Environment: macOS arm64, Python 3.11.17, ADK main (2.14.1). Docker transport is mocked; the real executor, result conversion, and flow are exercised by the regressions. Regression introduction is unknown.

主要語言
Python
星號
22.3k
分支
4.4k
平均合併
1 天 2 小時
30 天內合併 PR
6

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

google/adk-python 的其他 Issue

查看 google/adk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。