Skip to content

Commit

Permalink
Add handling for empty response (#808)
Browse files Browse the repository at this point in the history
In some cases, the llm may fail to generate any response (maybe timeout
or connection issues), it will result in None response and that creates
an error when it is passed in for regular expression tag parsing. This
PR fixes that by ensuring response is not None before passing in to
process.

---------

Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan authored Mar 5, 2025
1 parent f71b8e5 commit 9e4b7ce
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions agent/prototyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,18 +404,20 @@ def _container_tool_reaction(self, cur_round: int, response: str,
build_result: BuildResult) -> Optional[Prompt]:
"""Validates LLM conclusion or executes its command."""
prompt = prompt_builder.DefaultTemplateBuilder(self.llm, None).build([])
prompt = self._container_handle_bash_commands(response, self.inspect_tool,
prompt)

# Then build fuzz target.
prompt = self._container_handle_conclusion(cur_round, response,
build_result, prompt)
if prompt is None:
# Succeeded.
return None
if response:
prompt = self._container_handle_bash_commands(response, self.inspect_tool,
prompt)

# Then build fuzz target.
prompt = self._container_handle_conclusion(cur_round, response,
build_result, prompt)
if prompt is None:
# Succeeded.
return None

# Finally check invalid responses.
if not prompt.get():
if not response or not prompt.get():
prompt = self._container_handle_invalid_tool_usage(
self.inspect_tool, cur_round, response, prompt)

Expand Down

0 comments on commit 9e4b7ce

Please sign in to comment.