refine execute_code prompts: tool description + XML workflow guidance

This commit is contained in:
CREDO23 2026-04-13 19:51:34 +02:00
parent a71338e368
commit 5719a794a0

View file

@ -141,13 +141,12 @@ Use this to locate relevant document files/chunks before reading full files.
SURFSENSE_EXECUTE_CODE_TOOL_DESCRIPTION = """Executes a shell command in an isolated code execution environment. SURFSENSE_EXECUTE_CODE_TOOL_DESCRIPTION = """Executes a shell command in an isolated code execution environment.
Common data-science packages are pre-installed (pandas, numpy, matplotlib, Common data-science packages are pre-installed (pandas, numpy, matplotlib,
scipy, scikit-learn). Documents from the conversation are automatically scipy, scikit-learn).
made available run `ls` to discover them.
When to use this tool: always use execute_code for any task involving When to use this tool: use execute_code for numerical computation, data
numerical computation, data analysis, aggregation, or statistics. Write analysis, statistics, and any task that benefits from running shell
Python code to compute results and present the verified output. Never commands or Python code. Never perform arithmetic manually when this tool
perform arithmetic manually when this tool is available. is available.
Usage notes: Usage notes:
- No outbound network access. - No outbound network access.
@ -195,7 +194,13 @@ class SurfSenseFilesystemMiddleware(FilesystemMiddleware):
if self._sandbox_available: if self._sandbox_available:
system_prompt += ( system_prompt += (
"\n- execute_code: run shell commands in an isolated Python sandbox." "\n- execute_code: run shell commands in an isolated Python sandbox."
" Prefer this tool for any numerical computation or data analysis." "\n\n## Code Execution"
"\n\nUse execute_code for numerical computation, data analysis, and"
" statistics — never do arithmetic manually."
"\n\nDocuments here are XML-wrapped markdown, not raw data files."
" To work with them programmatically, read the document first,"
" extract the data, write it as a clean file (CSV, JSON, etc.),"
" and then run your code against it."
) )
super().__init__( super().__init__(