From 329d635dfa679610ee7c41ba66c9a71d045298c8 Mon Sep 17 00:00:00 2001 From: marko-kraemer Date: Thu, 10 Apr 2025 17:05:49 +0100 Subject: [PATCH] wip --- backend/agent/run.py | 20 ++++---------------- backend/agent/tools/sb_files_tool.py | 4 +++- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/backend/agent/run.py b/backend/agent/run.py index dbdc6c2a..df7cd68b 100644 --- a/backend/agent/run.py +++ b/backend/agent/run.py @@ -16,21 +16,6 @@ from agent.tools.utils.daytona_sandbox import daytona, create_sandbox, get_or_st load_dotenv() -# Custom JSON encoder to handle non-serializable types -class CustomJSONEncoder(json.JSONEncoder): - def default(self, obj): - # Handle ToolResult objects - if hasattr(obj, 'to_dict'): - return obj.to_dict() - # Handle datetime objects - if hasattr(obj, 'isoformat'): - return obj.isoformat() - # Return string representation for other unserializable objects - try: - return str(obj) - except: - return f"" - async def run_agent(thread_id: str, project_id: str, stream: bool = True, thread_manager: Optional[ThreadManager] = None, native_max_auto_continues: int = 25, max_iterations: int = 1): """Run the development agent with specified configuration.""" @@ -81,13 +66,16 @@ async def run_agent(thread_id: str, project_id: str, stream: bool = True, thread print(f"Running iteration {iteration_count}...") files_state = await files_tool.get_workspace_state() + + # Simple string representation + state_str = str(files_state) state_message = { "role": "user", "content": f""" Current development environment workspace state: -{json.dumps(files_state, indent=2, cls=CustomJSONEncoder)} +{state_str} """ } diff --git a/backend/agent/tools/sb_files_tool.py b/backend/agent/tools/sb_files_tool.py index 369f7be4..05ae2ddf 100644 --- a/backend/agent/tools/sb_files_tool.py +++ b/backend/agent/tools/sb_files_tool.py @@ -59,8 +59,10 @@ class SandboxFilesTool(SandboxToolsBase): print(f"Skipping binary file: {rel_path}") return files_state + except Exception as e: - return self.fail_response(f"Error getting workspace state: {str(e)}") + print(f"Error getting workspace state: {str(e)}") + return {} @openapi_schema({ "type": "function",