You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add logging to the agent to track model responses and tool execution.
- Introduce a `_truncate` helper for logging long strings.
- Enhance the Python tool to:
- Accept a list of extra allowed imports via configuration.
- Use AST to parse code and enforce import restrictions.
- Add `psutil` to default allowed imports and requirements.
- Update `load_default_tools` to accept settings for Python tool imports.
- Add verbose and quiet logging options to the CLI.
- Update README with examples and configuration details for Python tool imports.
Copy file name to clipboardExpand all lines: README.md
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,27 @@ The repo ships with a lightweight `Makefile` wired to [`uvx`](https://docs.astra
24
24
make run PROMPT="Summarize the latest message."
25
25
```
26
26
27
+
### Examples
28
+
29
+
#### Disk space:
30
+
31
+
```bash
32
+
| => python main.py "get disk space on current machine using python"
33
+
Disk Space:
34
+
Total: 926.35 GB
35
+
Used: 452.60 GB
36
+
Free: 473.76 GB
37
+
```
38
+
39
+
#### CPU usage:
40
+
41
+
```bash
42
+
| => python main.py "give current cpu usage" -v
43
+
INFO: Running tool 'python'.
44
+
INFO: Responding without tool use.
45
+
Current CPU usage: 16.5%
46
+
```
47
+
27
48
### Configuration
28
49
29
50
All settings live in `.env` (loaded with `python-dotenv`):
@@ -37,6 +58,7 @@ All settings live in `.env` (loaded with `python-dotenv`):
37
58
|`GEMINI_MODEL`| Defaults to `gemini-2.5-flash`. |
38
59
|`AGENT_SYSTEM_PROMPT`| Optional custom system prompt. |
39
60
|`REQUEST_TIMEOUT`| Request timeout in seconds (default `30`). |
61
+
|`PYTHON_TOOL_IMPORTS`| Optional comma list of extra python-tool imports (`os,sys,psutil`). |
40
62
41
63
The repository already contains `.env.example` with placeholders for these values.
42
64
@@ -51,6 +73,8 @@ python main.py --help
51
73
-`--max-turns`: maximum number of tool iterations.
52
74
-`--no-tools`: disable tool use.
53
75
-`--list-tools`: inspect available tools.
76
+
-`-v/--verbose`: increase logging (use `-vv` for debug-level traces about tool usage).
77
+
-`-q/--quiet`: suppress logs (errors only).
54
78
55
79
### Tools
56
80
@@ -59,7 +83,9 @@ Tools live under `simple_agent/tools` and implement a tiny interface (`name`, `d
59
83
-`time`: returns the current UTC timestamp.
60
84
-`calculator`: evaluates small arithmetic expressions safely.
61
85
-`file_reader`: dumps a snippet of a local text file (`path[:start-end]`).
62
-
-`python`: runs a short Python snippet in a separate interpreter (stdout/stderr returned).
86
+
-`python`: runs a short Python snippet in a separate interpreter (default imports include `math`, `json`, `os`, `sys`, `psutil`; extend via `PYTHON_TOOL_IMPORTS`).
87
+
88
+
The python tool executes with a module allowlist. By default it includes: `collections`, `datetime`, `functools`, `itertools`, `json`, `math`, `os`, `pathlib`, `psutil`, `random`, `statistics`, `sys`, `time`. Set `PYTHON_TOOL_IMPORTS` (comma separated) to append additional modules if needed.
63
89
64
90
Adding new tools only requires dropping a module next to the others and including it in `load_default_tools()`.
0 commit comments