From 9c6b682c733882b1b1e44ccbad3a8c5c9f075261 Mon Sep 17 00:00:00 2001 From: rob Date: Fri, 5 Dec 2025 21:39:48 -0400 Subject: [PATCH] fix: Improve AI auto-adjust prompt to prevent function wrapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The AI was generating function definitions instead of inline code. Updated the default prompt template to explicitly: - Request inline executable code, NOT function definitions - Clarify that variables are already available - Emphasize no wrapping in functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/smarttools/ui_urwid.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/smarttools/ui_urwid.py b/src/smarttools/ui_urwid.py index c27dee2..bb6fc08 100644 --- a/src/smarttools/ui_urwid.py +++ b/src/smarttools/ui_urwid.py @@ -1829,7 +1829,9 @@ class SmartToolsUI: ai_provider_select_btn = Button3DCompact("▼", on_press=show_ai_provider_dropdown) # Default prompt template for AI code generation/adjustment - default_ai_prompt = f"""Modify or generate Python code according to my instruction below. + default_ai_prompt = f"""Write inline Python code (NOT a function definition) according to my instruction. + +The code runs directly - variables are already available, no function needed. INSTRUCTION: [Describe what you want] @@ -1840,7 +1842,8 @@ CURRENT CODE: AVAILABLE VARIABLES: {', '.join(vars_available)} -Return ONLY the Python code, no explanations or markdown fencing.""" +IMPORTANT: Return ONLY executable inline code. Do NOT wrap in a function. +No explanations, no markdown fencing, just the code.""" # Multiline editable prompt for AI with DOS-style scrollbar ai_prompt_edit = TabPassEdit(edit_text=default_ai_prompt, multiline=True)