heaven_base.tools.write_block_report_tool
1# write_block_report_tool.py 2 3from ..baseheaventool import BaseHeavenTool, ToolResult, CLIResult, ToolError, ToolArgsSchema, ToolFailure 4import json 5from typing import Dict, Any, List 6from datetime import datetime 7 8class WriteBlockReportToolArgsSchema(ToolArgsSchema): 9 arguments: Dict[str, Dict[str, Any]] = { 10 'completed_tasks': { 11 'name': 'completed_tasks', 12 'type': 'list', 13 'description': 'List of tasks that have already been completed by the agent', 14 'items': { 'type': 'string' }, 15 'required': True 16 }, 17 'current_task': { 18 'name': 'current_task', 19 'type': 'str', 20 'description': 'The current task the agent is stuck on and cannot complete', 21 'required': True 22 }, 23 'explanation': { 24 'name': 'explanation', 25 'type': 'str', 26 'description': 'A detailed explanation of the problem encountered and why the agent is blocked', 27 'required': True 28 }, 29 'blocked_reason': { 30 'name': 'blocked_reason', 31 'type': 'str', 32 'description': 'A `blocked reason` must explain why you believe you are blocked and cannot solve this problem on your own. For example: "Need extra context. Unsure where to find the context required."', 33 'required': True 34 } 35 } 36 37def write_block_report_func(completed_tasks: List[str], current_task: str, explanation: str, blocked_reason: str) -> str: 38 """Create a block report when the agent is stuck and needs assistance.""" 39 report_data = { 40 "completed_tasks": completed_tasks, 41 "current_task": current_task, 42 "explanation": explanation, 43 "blocked_reason": blocked_reason, 44 "timestamp": datetime.now().isoformat() 45 } 46 47 # Use a consistent filepath 48 filepath = "/tmp/block_report.json" 49 50 # Write report to temp file 51 with open(filepath, 'w') as f: 52 json.dump(report_data, f) 53 54 # Return simple message 55 return "⚠️ Block Report created!\n🛑 Agent execution halted.\n🗣️ Say this in response: `I've created a block report and am waiting for the help I need`.\nThat will make it clear to the user." 56 57class WriteBlockReportTool(BaseHeavenTool): 58 name = "WriteBlockReportTool" 59 description = "Creates a Block Report for the system and stops the interaction. Use this tool ONLY when stuck and need help to proceed and want to end the current interaction completely. When writing a Block Report, provide details about what tasks you've completed, what you're stuck on, and why you need assistance. This tool is only for writing Block Reports." 60 func = write_block_report_func 61 args_schema = WriteBlockReportToolArgsSchema 62 is_async = False
9class WriteBlockReportToolArgsSchema(ToolArgsSchema): 10 arguments: Dict[str, Dict[str, Any]] = { 11 'completed_tasks': { 12 'name': 'completed_tasks', 13 'type': 'list', 14 'description': 'List of tasks that have already been completed by the agent', 15 'items': { 'type': 'string' }, 16 'required': True 17 }, 18 'current_task': { 19 'name': 'current_task', 20 'type': 'str', 21 'description': 'The current task the agent is stuck on and cannot complete', 22 'required': True 23 }, 24 'explanation': { 25 'name': 'explanation', 26 'type': 'str', 27 'description': 'A detailed explanation of the problem encountered and why the agent is blocked', 28 'required': True 29 }, 30 'blocked_reason': { 31 'name': 'blocked_reason', 32 'type': 'str', 33 'description': 'A `blocked reason` must explain why you believe you are blocked and cannot solve this problem on your own. For example: "Need extra context. Unsure where to find the context required."', 34 'required': True 35 } 36 }
Meta-validator for tool arguments ensuring LangChain compatibility
arguments: Dict[str, Dict[str, Any]] =
{'completed_tasks': {'name': 'completed_tasks', 'type': 'list', 'description': 'List of tasks that have already been completed by the agent', 'items': {'type': 'string'}, 'required': True}, 'current_task': {'name': 'current_task', 'type': 'str', 'description': 'The current task the agent is stuck on and cannot complete', 'required': True}, 'explanation': {'name': 'explanation', 'type': 'str', 'description': 'A detailed explanation of the problem encountered and why the agent is blocked', 'required': True}, 'blocked_reason': {'name': 'blocked_reason', 'type': 'str', 'description': 'A `blocked reason` must explain why you believe you are blocked and cannot solve this problem on your own. For example: "Need extra context. Unsure where to find the context required."', 'required': True}}
def
write_block_report_func( completed_tasks: List[str], current_task: str, explanation: str, blocked_reason: str) -> str:
38def write_block_report_func(completed_tasks: List[str], current_task: str, explanation: str, blocked_reason: str) -> str: 39 """Create a block report when the agent is stuck and needs assistance.""" 40 report_data = { 41 "completed_tasks": completed_tasks, 42 "current_task": current_task, 43 "explanation": explanation, 44 "blocked_reason": blocked_reason, 45 "timestamp": datetime.now().isoformat() 46 } 47 48 # Use a consistent filepath 49 filepath = "/tmp/block_report.json" 50 51 # Write report to temp file 52 with open(filepath, 'w') as f: 53 json.dump(report_data, f) 54 55 # Return simple message 56 return "⚠️ Block Report created!\n🛑 Agent execution halted.\n🗣️ Say this in response: `I've created a block report and am waiting for the help I need`.\nThat will make it clear to the user."
Create a block report when the agent is stuck and needs assistance.
58class WriteBlockReportTool(BaseHeavenTool): 59 name = "WriteBlockReportTool" 60 description = "Creates a Block Report for the system and stops the interaction. Use this tool ONLY when stuck and need help to proceed and want to end the current interaction completely. When writing a Block Report, provide details about what tasks you've completed, what you're stuck on, and why you need assistance. This tool is only for writing Block Reports." 61 func = write_block_report_func 62 args_schema = WriteBlockReportToolArgsSchema 63 is_async = False
Provider-agnostic tool base class with standardized results
description =
"Creates a Block Report for the system and stops the interaction. Use this tool ONLY when stuck and need help to proceed and want to end the current interaction completely. When writing a Block Report, provide details about what tasks you've completed, what you're stuck on, and why you need assistance. This tool is only for writing Block Reports."
def
func( completed_tasks: List[str], current_task: str, explanation: str, blocked_reason: str) -> str:
38def write_block_report_func(completed_tasks: List[str], current_task: str, explanation: str, blocked_reason: str) -> str: 39 """Create a block report when the agent is stuck and needs assistance.""" 40 report_data = { 41 "completed_tasks": completed_tasks, 42 "current_task": current_task, 43 "explanation": explanation, 44 "blocked_reason": blocked_reason, 45 "timestamp": datetime.now().isoformat() 46 } 47 48 # Use a consistent filepath 49 filepath = "/tmp/block_report.json" 50 51 # Write report to temp file 52 with open(filepath, 'w') as f: 53 json.dump(report_data, f) 54 55 # Return simple message 56 return "⚠️ Block Report created!\n🛑 Agent execution halted.\n🗣️ Say this in response: `I've created a block report and am waiting for the help I need`.\nThat will make it clear to the user."
Create a block report when the agent is stuck and needs assistance.
args_schema =
<class 'WriteBlockReportToolArgsSchema'>