Skip to content
Closed
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
6 changes: 5 additions & 1 deletion agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ def __init__(

async def monologue(self):
error_retries = 0 # counter for critical error retries
duplicate_retries = 0 # counter for duplicate response retries
while True:
try:
# loop data dictionary to pass to extensions
Expand Down Expand Up @@ -473,10 +474,12 @@ async def stream_callback(chunk: str, full: str):
if (
self.loop_data.last_response == agent_response
): # if assistant_response is the same as last message in history, let him know
# Increment duplicate counter for context
duplicate_retries += 1
# Append the assistant's response to the history
self.hist_add_ai_response(agent_response)
# Append warning message to the history
warning_msg = self.read_prompt("fw.msg_repeat.md")
warning_msg = self.read_prompt("fw.msg_repeat.md", retry_count=duplicate_retries)
self.hist_add_warning(message=warning_msg)
PrintStyle(font_color="orange", padding=True).print(
warning_msg
Expand All @@ -492,6 +495,7 @@ async def stream_callback(chunk: str, full: str):
return tools_result # break the execution if the task is done

error_retries = 0 # reset retry counter on successful iteration
duplicate_retries = 0 # reset duplicate counter on successful iteration

# exceptions inside message loop:
except InterventionException as e:
Expand Down
15 changes: 14 additions & 1 deletion prompts/fw.msg_repeat.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
You have sent the same message again. You have to do something else!
You have sent the same message again (attempt {{retry_count}}/3).

Your previous response was identical. This usually happens when:
- You're unsure how to proceed
- You're waiting for external input
- You're stuck in a reasoning loop

To break this loop, try ONE of these approaches:
1. If uncertain: Use the response tool to ask the user for clarification
2. If stuck: Try a different tool or approach to make progress
3. If blocked: Explain the blocker and what you need to proceed
4. If waiting: Check status and report current state instead of repeating

IMPORTANT: Do NOT repeat the same message. Choose a different action now.