Skip to content

feat: ContainerCodeExecutor should support input_files and output_files - #5321

Closed
hamdi-sakly wants to merge 10 commits into
google:mainfrom
hamdi-sakly:feat/container
Closed

hamdi-sakly wants to merge 10 commits into
google:mainfrom
hamdi-sakly:feat/container

Conversation

@hamdi-sakly

@hamdi-sakly hamdi-sakly commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

ContainerCodeExecutor currently ignores CodeExecutionInput.input_files and always returns an empty output_files list, making it impossible to:

  • Pass files into the container
  • Retrieve generated files from the container

Solution

Implement file I/O support using Docker's archive API:

Input files

Use container.put_archive() to copy input files into the container before code execution.

  • Input directory: /tmp/inputs/ (configurable via input_dir)

Output files

Use container.get_archive() to retrieve files from the container after execution.

  • Output directory: /tmp/outputs/ (configurable via output_dir)

Configuration changes

Added configurable parameters:

  • input_dir (default: /tmp/inputs)
  • output_dir (default: /tmp/outputs)

This approach is self-contained and does not require:

  • Host filesystem access
  • Docker bind mounts

Testing Plan

Unit Tests

Added:
tests/unittests/code_executors/test_container_code_executor.py

Test coverage

TestContainerCodeExecutorInit

  • Initialization with new parameters

TestExecuteCode

  • Basic execution
  • Input files handling
  • Output files retrieval

TestPutInputFiles

  • Tar archive creation
  • put_archive calls verification

TestGetOutputFiles

  • Archive extraction
  • Handling missing output directory (404 case)

TestMimeTypeGuessing

  • MIME type detection

Test Status

  • Unit tests pass locally (syntax validation successful)
  • Full pytest collection failed due to unrelated environment issue:

Fixes #5302

@rohityan rohityan self-assigned this Apr 16, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Apr 16, 2026
@hamdi-sakly

Copy link
Copy Markdown
Contributor Author

Hi @rohityan , I fixed the formatting tell me if you need any more clarifications

@rohityan rohityan added the tools [Component] This issue is related to tools label Apr 17, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @hamdi-sakly , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please fix the failing unit tests before we can proceed with the review.

@hamdi-sakly

Copy link
Copy Markdown
Contributor Author

Hi @rohityan the test failing is about importing docker in test environment , so I added docker to test .

@hamdi-sakly

Copy link
Copy Markdown
Contributor Author

@rohityan could you please do a review

@henrywang0314

Copy link
Copy Markdown

any updates?

copybara-service Bot pushed a commit that referenced this pull request Oct 28, 2026
Merge #5321

Fixes #5302

Executions on one ContainerCodeExecutor now run one at a time, since they
share one container and its input and output directories. execute_code
raises if those directories cannot be emptied, if the read-back of
output_dir exceeds 100 MiB, or if an output name starts with `user:`.
String input file content must be base64.

PiperOrigin-RevId: 1009254901
@adk-bot

adk-bot commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Thank you @hamdi-sakly for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit effd641.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Oct 28, 2026
@adk-bot adk-bot closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged request clarification [Status] The maintainer need clarification or more information from the author tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: ContainerCodeExecutor should support input_files and output_files

4 participants