Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional statement expanded for errored API response (close #560) #628

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superagi/agent/super_agi.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def execute(self, workflow_step: AgentWorkflowStep):
total_tokens = current_tokens + TokenCounter.count_message_tokens(response, self.llm.get_model())
self.update_agent_execution_tokens(current_calls, total_tokens)

if response['content'] is None:
if 'content' not in response or response['content'] is None:
raise RuntimeError(f"Failed to get response from llm")
assistant_reply = response['content']

Expand Down
8 changes: 7 additions & 1 deletion superagi/jobs/agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,13 @@ def execute_next_action(self, agent_execution_id):

agent_workflow_step = session.query(AgentWorkflowStep).filter(
AgentWorkflowStep.id == agent_execution.current_step_id).first()
response = spawned_agent.execute(agent_workflow_step)

try:
response = spawned_agent.execute(agent_workflow_step)
except RuntimeError as e:
# If our execution encounters an error we return and attempt to retry
return

if "retry" in response and response["retry"]:
response = spawned_agent.execute(agent_workflow_step)
agent_execution.current_step_id = agent_workflow_step.next_step_id
Expand Down