diff --git a/AGENTS.md b/AGENTS.md index bc7d0b3..215bf31 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,7 +30,7 @@ Simulate three internal specialists: - Output executable code first. - Include minimal, relevant explanation if necessary. - When you have fully satisfied the user's request and provided a complete answer, - you MUST call the `task_mark_complete` tool with a summary of what was accomplished and a final message for the user. This signals that the task is finished. + you MUST call the `msg_task_complete` tool with a summary of what was accomplished and a final message for the user. This signals that the task is finished. - Debrief the user before marking the task complete, ensuring they understand the changes made and any implications. ## Important Files diff --git a/pyproject.toml b/pyproject.toml index 192038d..a94bfe8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ heavy-agent = "source_agent.heavy:main" [project] requires-python = ">=3.10" -version = "0.0.11" +version = "0.0.12" name = "source-agent" description = "Simple coding agent." readme = ".github/README.md" diff --git a/src/source_agent/agents/code.py b/src/source_agent/agents/code.py index 9f71d18..37d48b2 100644 --- a/src/source_agent/agents/code.py +++ b/src/source_agent/agents/code.py @@ -58,22 +58,28 @@ def run(self, user_prompt: str = None, max_steps: int = 50): if message.tool_calls: for tool_call in message.tool_calls: print(f"πŸ”§ Calling: {tool_call.function.name}") - print(f"πŸ“ Args: {tool_call.function.arguments}") + # print(f"πŸ“ Args: {tool_call.function.arguments}") result = self.handle_tool_call(tool_call) self.messages.append(result) - print("βœ… Result:", result) + # print("βœ… Result:", result) - if tool_call.function.name == "task_mark_complete": + # # TODO - Better message handling + # if tool_call.function.name == "msg_final_answer": + # print("βœ… Final answer received!") + # return result + + if tool_call.function.name == "msg_task_complete": print("πŸ’― Task marked complete!") return result - else: - print("πŸ’­ No tools; continuing") + # else: + # # print("πŸ’­ No tools; continuing") + # pass print("\n" + "-" * 40 + "\n") - print("🚨 Max steps reached without task completion.") + # print("🚨 Max steps reached without task completion.") return {"error": "Max steps reached without task completion."} def handle_tool_call(self, tool_call): diff --git a/src/source_agent/entrypoint.py b/src/source_agent/entrypoint.py index fb4e102..dc0019a 100644 --- a/src/source_agent/entrypoint.py +++ b/src/source_agent/entrypoint.py @@ -169,7 +169,6 @@ def main() -> int: help="Run in interactive step‑through mode", ) parser.add_argument( - "-h", "--heavy", action="store_true", default=False, diff --git a/src/source_agent/tools/msg_final_answer.py b/src/source_agent/tools/msg_final_answer.py new file mode 100644 index 0000000..634f127 --- /dev/null +++ b/src/source_agent/tools/msg_final_answer.py @@ -0,0 +1,34 @@ +# ruff: noqa: E501 + +from datetime import datetime +from .tool_registry import registry + + +@registry.register( + name="msg_final_answer", + description="Final summary of the task. Call this tool when the user's original request has been fully satisfied and you have provided a complete answer. This signals task completion and exits the agent loop.", + parameters={ + "type": "object", + "properties": { + "answer": { + "type": "string", + "description": "The final answer to the user's question or request.", + }, + }, + "required": ["answer"], + }, +) +def msg_final_answer(answer: str): + """ + Final summary of the task. + """ + timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + + return { + "success": True, + "content": { + "status": "answered", + "answer": answer, + "timestamp": timestamp, + }, + } diff --git a/src/source_agent/tools/task_mark_complete.py b/src/source_agent/tools/msg_task_complete.py similarity index 92% rename from src/source_agent/tools/task_mark_complete.py rename to src/source_agent/tools/msg_task_complete.py index 5eb1f27..f2039e4 100644 --- a/src/source_agent/tools/task_mark_complete.py +++ b/src/source_agent/tools/msg_task_complete.py @@ -4,7 +4,7 @@ @registry.register( - name="task_mark_complete", + name="msg_task_complete", description="REQUIRED: Call this tool when the user's original request has been fully satisfied and you have provided a complete answer. This signals task completion and exits the agent loop.", parameters={ "type": "object", @@ -21,7 +21,7 @@ "required": ["task_summary", "completion_message"], }, ) -def task_mark_complete(task_summary: str, completion_message: str) -> dict: +def msg_task_complete(task_summary: str, completion_message: str) -> dict: try: timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")