Skip to content

Commit 3514032

Browse files
committed
added prints in code agent
1 parent f495cc5 commit 3514032

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

gui_agents/s3/agents/code_agent.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ def execute(self, task_instruction: str, screenshot: str, env_controller) -> Dic
115115
if env_controller is None:
116116
raise ValueError("env_controller is required for code execution")
117117

118+
print(f"\n🚀 STARTING CODE EXECUTION")
119+
print("=" * 60)
120+
print(f"Task: {task_instruction}")
121+
print(f"Budget: {self.budget} steps")
122+
print("=" * 60)
123+
118124
logger.info(f"Starting code execution for task: {task_instruction}")
119125
logger.info(f"Budget: {self.budget} steps")
120126

@@ -135,6 +141,12 @@ def execute(self, task_instruction: str, screenshot: str, env_controller) -> Dic
135141
# Get assistant response (thoughts and code)
136142
response = call_llm_safe(self.agent, temperature=1)
137143

144+
# Print to terminal for immediate visibility
145+
print(f"\n🤖 CODING AGENT RESPONSE - Step {step_count + 1}/{self.budget}")
146+
print("=" * 60)
147+
print(response)
148+
print("=" * 60)
149+
138150
# Log the latest message from the coding agent (untruncated)
139151
logger.info(
140152
f"CODING_AGENT_LATEST_MESSAGE - Step {step_count + 1}:\n{response}"
@@ -156,10 +168,18 @@ def execute(self, task_instruction: str, screenshot: str, env_controller) -> Dic
156168
# Check for completion signals
157169
action_upper = action.upper().strip()
158170
if action_upper == "DONE":
171+
print(f"\n✅ TASK COMPLETED - Step {step_count + 1}")
172+
print("=" * 60)
173+
print("Agent signaled task completion")
174+
print("=" * 60)
159175
logger.info(f"Step {step_count + 1}: Task completed successfully")
160176
completion_reason = "DONE"
161177
break
162178
elif action_upper == "FAIL":
179+
print(f"\n❌ TASK FAILED - Step {step_count + 1}")
180+
print("=" * 60)
181+
print("Agent signaled task failure")
182+
print("=" * 60)
163183
logger.info(f"Step {step_count + 1}: Task failed by agent request")
164184
completion_reason = "FAIL"
165185
break
@@ -175,6 +195,18 @@ def execute(self, task_instruction: str, screenshot: str, env_controller) -> Dic
175195
message = result.get("message", "")
176196
status = result.get("status", "")
177197

198+
# Print execution result to terminal for immediate visibility
199+
print(f"\n⚡ CODE EXECUTION RESULT - Step {step_count + 1}")
200+
print("-" * 50)
201+
print(f"Status: {status}")
202+
if output:
203+
print(f"Output:\n{output}")
204+
if error:
205+
print(f"Error:\n{error}")
206+
if message and not output and not error:
207+
print(f"Message:\n{message}")
208+
print("-" * 50)
209+
178210
log_lines = [
179211
f"CODING_AGENT_EXECUTION_RESULT - Step {step_count + 1}:",
180212
f"Status: {status}" if status else None,
@@ -197,6 +229,11 @@ def execute(self, task_instruction: str, screenshot: str, env_controller) -> Dic
197229
formatted_log = "\n".join([line for line in log_lines if line])
198230
logger.info(formatted_log)
199231
else:
232+
print(f"\n⚠️ NO CODE BLOCK FOUND - Step {step_count + 1}")
233+
print("-" * 50)
234+
print("Action did not contain executable code")
235+
print("-" * 50)
236+
200237
logger.warning(f"Step {step_count + 1}: No code block found in action")
201238
result = {"status": "skipped", "message": "No code block found"}
202239
logger.info(
@@ -215,6 +252,10 @@ def execute(self, task_instruction: str, screenshot: str, env_controller) -> Dic
215252

216253
# Handle budget exhaustion
217254
if "completion_reason" not in locals():
255+
print(f"\n⏰ BUDGET EXHAUSTED - {step_count} steps completed")
256+
print("=" * 60)
257+
print(f"Maximum budget of {self.budget} steps reached")
258+
print("=" * 60)
218259
logger.info(f"Budget exhausted after {step_count} steps")
219260
completion_reason = f"BUDGET_EXHAUSTED_AFTER_{step_count}_STEPS"
220261

0 commit comments

Comments
 (0)