From 89792515413558f2bad5bb17207806f27d2eadea Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Wed, 7 May 2025 07:04:14 -0300 Subject: [PATCH] refactor(agent): update condition evaluation logging in workflow agent --- Dockerfile | 2 +- src/services/workflow_agent.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ea1c043c..3acca611 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,4 +32,4 @@ ENV PORT=8000 \ # Expose port EXPOSE 8000 -CMD alembic upgrade head && uvicorn src.main:app --host $HOST --port $PORT \ No newline at end of file +CMD uvicorn src.main:app --host $HOST --port $PORT \ No newline at end of file diff --git a/src/services/workflow_agent.py b/src/services/workflow_agent.py index 5f1c7b21..788de261 100644 --- a/src/services/workflow_agent.py +++ b/src/services/workflow_agent.py @@ -204,6 +204,7 @@ class WorkflowAgent(BaseAgent): # Check all conditions conditions_met = [] + condition_details = [] for condition in conditions: condition_id = condition.get("id") condition_data = condition.get("data", {}) @@ -216,7 +217,14 @@ class WorkflowAgent(BaseAgent): ) if self._evaluate_condition(condition, state): conditions_met.append(condition_id) + condition_details.append( + f"{field} {operator} '{expected_value}' āœ…" + ) print(f" āœ… Condition {condition_id} met!") + else: + condition_details.append( + f"{field} {operator} '{expected_value}' āŒ" + ) # Check if the cycle reached the limit (extra security) if cycle_count >= 10: @@ -247,16 +255,21 @@ class WorkflowAgent(BaseAgent): "condition_evaluated": label, "content_evaluated": content, "conditions_met": conditions_met, + "condition_details": condition_details, "cycle": cycle_count, } + # Prepare a more descriptive message about the conditions + conditions_result_text = "\n".join(condition_details) + condition_summary = f"TRUE" if conditions_met else "FALSE" + condition_content = [ Event( author="agent", content=Content( parts=[ Part( - text=f"Condition evaluated: {label} with {str(conditions_met)}" + text=f"Condition evaluated: {label}\nResult: {condition_summary}\nDetails:\n{conditions_result_text}" ) ] ), @@ -674,7 +687,8 @@ class WorkflowAgent(BaseAgent): print(f"\nāœ… FINAL RESULT: {final_content[:100]}...") for content in final_content: - yield content + if content.author != "user": + yield content # Execute sub-agents for sub_agent in self.sub_agents: