Skip to content

Commit c55825a

Browse files
Merge pull request #15 from heroku/remove_use_temp_dir_llm_arg
Turns tempdir LLM argument into a configvar
2 parents 11747c6 + bd464a3 commit c55825a

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

app.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"STDIO_MODE_ONLY": {
1616
"description": "Only allow tool requests via STDIO mode?",
1717
"value": "false"
18+
},
19+
"USE_TEMP_DIR": {
20+
"description": "If True, gems are installed in an isolated temporary directory and will not affect or reuse the user's ~/.gem folder. Not a secure sandbox.",
21+
"value": "false"
1822
}
1923
},
2024
"formation": [

example_clients/test_sse.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ def mcp(method_name, args=None):
3232
3333
Examples:
3434
python example_clients/test_sse.py mcp list_tools
35-
python example_clients/test_sse.py mcp call_tool --args '{"name": "fetch_webpage_and_markdownify", "arguments": {"url": "https://example.com"}}'
36-
"""
35+
36+
python example_clients/test_sse.py mcp call_tool --args '{
37+
"name": "code_exec_ruby",
38+
"arguments": {
39+
"code": "puts Array.new(100) { rand(1..100) }.join(\", \")",
40+
"packages": [""]
41+
}
42+
}' | jq """
3743
result = asyncio.run(run(method_name, args))
3844
print(json.dumps(result.model_dump(), indent=2))
3945

src/code_execution.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import tempfile
55
from typing import Annotated, Optional, List, Dict, Any
66
from pydantic import Field
7+
# local:
8+
from src import config
79

810
def run_command(cmd: List[str], env: Optional[Dict[str, str]] = None) -> Dict[str, Any]:
911
"""Executes a command using subprocess and returns output and errors."""
@@ -108,15 +110,7 @@ def code_exec_ruby(
108110
packages: Annotated[
109111
Optional[List[str]],
110112
Field(description="Optional list of gem names to install before execution.")
111-
] = None,
112-
use_temp_dir: Annotated[
113-
bool,
114-
Field(description=(
115-
"If True, code and dependencies are run in a temporary working directory. "
116-
"Gems are installed in an isolated directory and will not affect or reuse the user's ~/.gem folder. "
117-
"Not a secure sandbox."
118-
))
119-
] = False
113+
] = None
120114
) -> Dict[str, Any]:
121115
"""Executes a Ruby code snippet with optional gem dependencies.
122116
@@ -132,7 +126,7 @@ def code_exec_ruby(
132126
- 'stdout': Captured standard output.
133127
- 'stderr': Captured standard error or install failure messages.
134128
"""
135-
if use_temp_dir:
129+
if config.USE_TEMP_DIR:
136130
return run_in_tempdir(code, packages)
137131

138132
# Otherwise, you can rely on pre-installed shared packages, if they exist:

src/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def get_env_variable(var_name, required=True):
1717
PORT = int(os.environ.get('PORT', 8000))
1818
WEB_CONCURRENCY = int(os.environ.get('WEB_CONCURRENCY', 1))
1919
STDIO_MODE_ONLY = os.getenv("STDIO_MODE_ONLY", "false").lower() == "true"
20+
USE_TEMP_DIR = os.getenv("USE_TEMP_DIR", "false").lower() == "true"
2021

2122
# Local or Not:
2223
is_one_off_dyno = os.getenv("DYNO") is not None

0 commit comments

Comments
 (0)