feat(cloud-query): add python interpeter tool to tool query grpc server - #4029
feat(cloud-query): add python interpeter tool to tool query grpc server#4029floreks wants to merge 14 commits into
Conversation
- Added `RunPythonInput` and `RunPythonOutput` message types in `toolquery.proto` for Python script execution - Introduced Python worker logic using a limited subset of Monty, with controlled execution environment and resources - Enhanced `Server` with graceful shutdown and service cleanup to safely terminate background processes - Updated `ToolQueryService` to support Python script execution with context handling - Added `Closer` interface for services that require resource cleanup - Implemented protocol versioning and request handling for Python execution in the worker process - Extended Elixir definitions in toolquery.pb.ex to include Python RPC services - Updated workbench documentation to incorporate Python tool information
- Removed obsolete Python protocol and worker logic - Introduced new worker and contract packages for improved modularity - Added `internal/worker/os.go` for handling OS-level operations in a sandboxed environment - Enhanced `ToolQueryService` to utilize the refactored Python runner interface - Simplified error handling and error message generation - Improved code organization by separating logic into distinct packages
Soffi AI SummaryThis PR adds sandboxed Python execution capability to the Cloud Query gRPC service, exposing it as a new Key changes:
Commits
Updated: 2026-08-21 12:59 UTC |
…-python-tool-in-tool-query-grpc-server
Greptile SummaryThe PR adds sandboxed Monty Python execution to Cloud Query and exposes it as a workbench tool.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| go/cloud-query/internal/tools/python/internal/pool/pool.go | Implements the bounded worker subprocess pool, request queueing, recycling, cancellation, and shutdown lifecycle. |
| go/cloud-query/internal/tools/python/internal/worker/runtime.go | Executes validated requests in fresh Monty sessions under configured runtime limits. |
| go/cloud-query/internal/service/toolquery.go | Initializes the Python runner, exposes the RunPython RPC, translates errors, and closes workers during shutdown. |
| go/cloud-query/api/proto/toolquery.proto | Adds the RunPython request, response, and ToolQuery service method contract. |
| lib/console/ai/tools/workbench/python.ex | Integrates the Cloud Query Python endpoint as a Console AI workbench tool. |
| charts/console/values.yaml | Raises Cloud Query’s memory request and introduces a memory limit for the Python runtime workload. |
Reviews (4): Last reviewed commit: "refactor(tests): remove MemoryEngineTest..." | Re-trigger Greptile
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
- Increased Monty execution time to 60 seconds - Updated wall timeout to 65 seconds and Monty-managed memory to 100 MiB - Reduced recursion limit to 100 frames - Updated README and API reference documentation to reflect new limits - Added tests for wall timeout and Monty runtime limit validation
- Bumped Go version in `console/go/helm-test` from 1.26.5 to 1.26.6 - Added various indirect dependencies to `console/go/ai-proxy` - Updated `google.golang.org/genproto/googleapis/rpc` to new version in multiple modules - Aligned proto dependencies across projects
- Updated Go version from 1.26.5 to 1.26.6 in various modules - Ensured consistent Go version across all sub-projects
- Updated Go version from 1.26.5 to 1.26.6 for consistency across all Dockerfiles - Aligned version in various service and component Dockerfiles including datastore, deployment-operator, ai-proxy, and others
- Bumped Go version from 1.26.5 to 1.26.6 across all relevant Dockerfiles - Ensured version consistency in Kubernetes agent, cloud-query, and deployment-operator components - Modified GitHub workflow to align Go version with Dockerfile updates
- Changed `truncatedCause` to `truncatedCauseError` for clarity and consistency - Simplified detail truncation logic in `truncateDetail` function
- Added `--chown=65532:65532` to `COPY` command in `sentinel-harness/terratest.Dockerfile` to ensure correct file ownership within the container.
- Adjusted `stdout` newline representation in `python_test.exs` to use consistent newline character `\n`
|
plural deploy to dev |
- Added `MemoryEngineTest` in `memory_engine_test.exs` to verify structured tool result serialization before next completion - Utilized `Mimic` for mocking provider calls - Included `MapTool` as an embedded schema for testing purposes - Enhanced `tool_msg` logic for proper result serialization in `memory_engine.ex`
|
plural deploy to dev |
- Removed unnecessary recursion in `tool_msg` function within `memory_engine.ex` for improved clarity and efficiency
…utputs - Deleted `MemoryEngineTest` module for test suite simplification - Removed unused function `tool_result_content` in `memory_engine.ex` for cleaner code - Updated Python test cases to handle serialized outputs using `Output.json` - Added test for bounding oversized Python output in `python_test.exs` to ensure result size compliance
|
plural deploy to dev |
This pull request introduces a new feature to the Cloud Query service: support for sandboxed Python execution using Monty (via the
gomontylibrary), alongside the existing Lua support. It also upgrades the Go toolchain and dependencies across the project to version 1.26.6 and increases the default memory allocation for the Cloud Query service. The changes include updates to documentation, Dockerfiles, proto definitions, and service initialization logic.New Python Execution Feature:
RunPythongRPC endpoint to theToolQueryservice, allowing execution of Monty's limited Python subset in a secure sandbox. This includes new proto messages (RunPythonInput,RunPythonOutput) and updates to API documentation describing the feature, its constraints, and usage. [1] [2] [3] [4] [5] [6]Dependency and Toolchain Upgrades:
go.modfiles and Dockerfiles for build consistency and security. [1] [2] [3] [4] [5] [6] [7]github.com/ewhauser/gomontyfor Python sandboxing, and other indirect dependencies for improved functionality and compatibility. [1] [2] [3] [4] [5] [6]Resource Allocation Improvements:
charts/console/values.yamlto better support the new Python sandboxing feature and improve reliability.Documentation Updates:
Internal Service Initialization:
Test Plan
Test environment: https://console.plrl-dev-aws.onplural.sh/
Checklist
Plural Flow: console