Skip to content

fix: capture Python tool execution output#145

Open
Jarvis636431 wants to merge 1 commit into
jd-opensource:mainfrom
Jarvis636431:agent/capture-python-tool-output
Open

fix: capture Python tool execution output#145
Jarvis636431 wants to merge 1 commit into
jd-opensource:mainfrom
Jarvis636431:agent/capture-python-tool-output

Conversation

@Jarvis636431

Copy link
Copy Markdown

Summary

Fixes python_tools.run_python_code so agents receive output produced by executed Python code instead of only a generic success message.

Closes #105.

Changes

  • Capture and return standard output.
  • Capture standard error and mark it with a [stderr] prefix.
  • Preserve variable_to_return and no-output behavior.
  • Preserve explicitly supplied empty execution namespaces.
  • Add focused unit tests for stdout, stderr, combined output, and namespaces.

Validation

  • python -m pytest tests/unittest/test_tool/test_python_tools.py -q — 7 passed.
  • ruff format --check oxygent/preset_tools/python_tools.py tests/unittest/test_tool/test_python_tools.py — passed.
  • docformatter --check oxygent/preset_tools/python_tools.py — passed.
  • Full unit suite: 342 passed, 13 skipped, 5 unrelated failures because train-ticket tests require access to 12306.cn, which was unavailable in the test environment.

@Jarvis636431
Jarvis636431 marked this pull request as ready for review July 13, 2026 08:44
@Jarvis636431
Jarvis636431 force-pushed the agent/capture-python-tool-output branch from 5b9ae53 to 5474e23 Compare July 13, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] python_tools.run_python_code does not capture stdout/stderr, causing LLM hallucinations

1 participant