Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sandbox)🔒: Add secure script execution for LLM agents using Docker #166

Merged
merged 16 commits into from
Jan 28, 2025

Conversation

ericmjl
Copy link
Owner

@ericmjl ericmjl commented Jan 12, 2025

  • Implemented a secure sandbox environment for executing agent-generated Python scripts.
  • Introduced Docker-based isolation with resource and security constraints.
  • Added metadata handling for script dependencies and execution context.
  • Included comprehensive tests for the sandbox functionality.

- Implemented a secure sandbox environment for executing agent-generated Python scripts.
- Introduced Docker-based isolation with resource and security constraints.
- Added metadata handling for script dependencies and execution context.
- Included comprehensive tests for the sandbox functionality.
Copy link

github-actions bot commented Jan 12, 2025

PR Preview Action v1.4.8
🚀 Deployed preview to https://ericmjl.github.io/llamabot/pr-preview/pr-166/
on branch gh-pages at 2025-01-28 14:02 UTC

ericmjl and others added 15 commits January 12, 2025 14:39
…er container.

- Modified the container run command to use 'python' explicitly for script execution.
- This change prevents execution issues related to script file permissions or shebang configurations.
…t handling

- Added new dependencies to support enhanced functionality.
- Refactored argument handling in the ToolToCall class for better clarity and maintainability.
- Updated the pyproject.toml and lock files to reflect the latest dependency versions.
…used parameters

- Removed the 'purpose' parameter from the 'write_and_execute_script' function and related metadata.
- Added descriptions to Pydantic model fields for better documentation.
- Adjusted caching logic to skip specific tool results.
…ument structure

- Modified the test_tool_to_call_model test to use the updated ToolArguments and CachedArguments structures.
- Ensured the test validates the new list-based argument and cached result formats.
- Updated the `hash_result` function to return only the first 8 characters of the SHA256 hash.
- Modified test cases to validate the new hash length constraint.
…handling for improved clarity and functionality

- Revised the `write_and_execute_script` function to accept dependencies as a comma-separated string.
- Enhanced the `ScriptExecutor` class to provide detailed execution results including stdout, stderr, and status.
- Improved metadata handling and script writing for better maintainability.
…cution improvements

- Added a new tool for internet search using DuckDuckGo API.
- Improved script execution by modifying Python version handling and result processing.
- Refactored memory caching logic to exclude specific tool results.
- Enhanced sandbox environment with increased memory and dedicated cache space.
- Deleted the 'write_and_execute_script' function from the functions list.
- Ensured the functionality remains intact without the removed function.
- Updated the hash for the llamabot package in the lockfile.
- Updated the dependency version for 'litellm' in both 'pixi.lock' and 'pyproject.toml'.
- Added a new notebook 'agentbot.ipynb' demonstrating the usage of the 'AgentBot' class.
- Enhanced 'structuredbot_json.ipynb' with additional examples and model experiments.
- Replaced 'ToolArguments' with 'ToolArgument' in test cases.
- Ensured the test cases align with the updated class definitions.
- Updated typing for volume configuration to use dict instead of Mapping.
- Added RuntimeError raising for script execution failures with detailed error messages.
- Modified test cases to validate new error handling and output parsing.
…dencies.

- Deleted the test_script_with_dependencies function from test_sandbox.py.
- This was deemed unnecessary because we do allow access to the internet from within the container.
@ericmjl ericmjl merged commit b73e2b0 into main Jan 28, 2025
11 checks passed
@ericmjl ericmjl deleted the agents-write-tools branch January 28, 2025 23:24
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.

1 participant