stellar413 commited on
Commit
7ea9284
·
1 Parent(s): 97e46c7

Fix CrewAI compatibility and agent input parameter extraction

Browse files
Files changed (1) hide show
  1. services/agents/base_agent.py +16 -3
services/agents/base_agent.py CHANGED
@@ -147,13 +147,26 @@ class BaseUtilityAgent(ABC):
147
  start_time = datetime.now(timezone.utc)
148
 
149
  try:
 
 
 
 
 
 
 
 
 
 
 
 
150
  # Step 1: Call the original utility function
151
  # This ensures backward compatibility and correctness
152
- utility_result = self.utility_function(input_data)
153
 
154
  # Step 2: Create a CrewAI task for the agent to validate/enhance the result
155
  # The agent doesn't replace the utility - it adds intelligence on top
156
- task_description = self._prepare_task_description(input_data)
 
157
 
158
  task = Task(
159
  description=task_description,
@@ -186,7 +199,7 @@ class BaseUtilityAgent(ABC):
186
  }
187
 
188
  # Step 5: Log execution
189
- self._log_execution(input_data, result, execution_time, True)
190
 
191
  return result
192
 
 
147
  start_time = datetime.now(timezone.utc)
148
 
149
  try:
150
+ # Handle task message structure from MasterOrchestrator
151
+ # Task messages have structure: {"description": "...", "input": {...}}
152
+ # We need to extract the actual input for the utility
153
+ if "input" in input_data and "description" in input_data:
154
+ # This is a task message from MasterOrchestrator
155
+ actual_input = input_data["input"]
156
+ task_description = input_data["description"]
157
+ else:
158
+ # Direct call (backward compatibility)
159
+ actual_input = input_data
160
+ task_description = None
161
+
162
  # Step 1: Call the original utility function
163
  # This ensures backward compatibility and correctness
164
+ utility_result = self.utility_function(actual_input)
165
 
166
  # Step 2: Create a CrewAI task for the agent to validate/enhance the result
167
  # The agent doesn't replace the utility - it adds intelligence on top
168
+ if not task_description:
169
+ task_description = self._prepare_task_description(actual_input)
170
 
171
  task = Task(
172
  description=task_description,
 
199
  }
200
 
201
  # Step 5: Log execution
202
+ self._log_execution(actual_input, result, execution_time, True)
203
 
204
  return result
205