Skip to content

Commit

Permalink
Readd retry_message
Browse files Browse the repository at this point in the history
  • Loading branch information
aorwall committed Jul 31, 2024
1 parent 2ee9cc9 commit 25759b5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions moatless/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def _set_state_loop(self, state: AgenticState):
def retries(self) -> int:
retries = 0
for action in reversed(self._current_transition.actions):
if action.retry_message:
if action.trigger == "retry":
retries += 1
else:
return retries
Expand All @@ -281,7 +281,7 @@ def retry_messages(self, state: AgenticState) -> list[Message]:
return messages

for action in self._current_transition.actions:
if action.retry_message:
if action.trigger == "retry":
if isinstance(action.action, Content):
messages.append(
AssistantMessage(
Expand Down Expand Up @@ -504,6 +504,7 @@ def _run(self):
TrajectoryAction(
action=action,
trigger=response.trigger,
retry_message=response.retry_message,
completion_cost=cost,
input_tokens=input_tokens,
output_tokens=output_tokens,
Expand Down
2 changes: 1 addition & 1 deletion moatless/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def required_fields(cls) -> set[str]:
def retries(self) -> int:
retries = 0
for action in reversed(self.loop._current_transition.actions):
if action.retry_message:
if action.trigger == "retry":
retries += 1
else:
return retries
Expand Down
1 change: 1 addition & 0 deletions moatless/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
class TrajectoryAction(BaseModel):
action: ActionRequest
trigger: Optional[str]
retry_message: Optional[str]
completion_cost: Optional[float] = None
input_tokens: Optional[int] = None
output_tokens: Optional[int] = None
Expand Down

0 comments on commit 25759b5

Please sign in to comment.