From 5fc6a7330bab2fed6ed581403b338261d696427b Mon Sep 17 00:00:00 2001 From: ayush Date: Fri, 10 Apr 2026 14:08:34 +0530 Subject: [PATCH] feat:Implemented Ask Tool --- lambda_agent/agent.py | 8 ++++++-- lambda_agent/tools.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lambda_agent/agent.py b/lambda_agent/agent.py index 70a1438..6083cef 100644 --- a/lambda_agent/agent.py +++ b/lambda_agent/agent.py @@ -24,8 +24,12 @@ def __init__(self): "You are Lambda, a minimal and highly efficient AI coding agent. " "Your primary goal is to help the user by writing code, executing commands, " "and managing files. You have access to tools that let you read files, " - "write files, and run shell commands. Whenever the user asks you to do " - "something that requires these tools, you should use them autonomously. " + "write files, run shell commands, and ask the user questions. " + "Whenever the user asks you to do something that requires these tools, " + "you should use them autonomously. " + "CRITICAL: Do not guess the user's intent. Guessing is bad. " + "If there is any confusion or ambiguity, you MUST use the ask_user tool " + "to clarify the job with the human. You can ask multiple questions. " "Be concise and professional." ) diff --git a/lambda_agent/tools.py b/lambda_agent/tools.py index e56304c..756e869 100644 --- a/lambda_agent/tools.py +++ b/lambda_agent/tools.py @@ -151,12 +151,27 @@ def search_repo(query: str, path: str = ".") -> str: return f"Error searching repository: {str(e)}" +def ask_user(question: str) -> str: + """Asks the user a clarifying question and returns their answer. + + Args: + question: The question to ask the user. + """ + try: + print(f"\n🤔 Agent asks: {question}") + answer = input("Your answer: ") + return answer + except Exception as e: + return f"Error asking user: {str(e)}" + + # A dictionary mapping tool names to Python functions for dynamic execution TOOL_EXECUTORS = { "read_file": read_file, "write_file": write_file, "run_command": run_command, "search_repo": search_repo, + "ask_user": ask_user, } # The list of raw Python functions for the Gemini SDK to auto-generate schemas @@ -165,4 +180,5 @@ def search_repo(query: str, path: str = ".") -> str: write_file, run_command, search_repo, + ask_user, ]