Skip to content

Commit d1331f6

Browse files
committed
✨ ui updated
1 parent e6a486b commit d1331f6

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

src/agent.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ def get_friendly_quota_message(provider: str) -> str:
7373
# Type for status callback.
7474
StatusCallback = Optional[Callable[[str, str], None]]
7575

76-
# Maximum number of tool call rounds to prevent infinite loops.
77-
MAX_TOOL_ROUNDS = 3
76+
# Maximum number of tool call rounds.
77+
# High limit to allow complex multi-step tasks to complete.
78+
# The model will naturally stop when task is done.
79+
MAX_TOOL_ROUNDS = 50
7880

7981
# Pattern to detect file references with @ symbol.
8082
# Matches @path/to/file or @./relative/path or @C:\windows\path
@@ -716,16 +718,39 @@ def _process_tool_calls_with_retry(
716718
pending_tool_calls.extend(text_tool_calls)
717719

718720
# If the model wants to use more tools, process them (for multi-step tasks)
719-
if pending_tool_calls and allow_more_tools:
720-
log_debug(f"Processing additional tools (round {round_num + 1})")
721-
if follow_up_response: self.messages.append({"role": "assistant", "content": follow_up_response})
722-
723-
return self._process_tool_calls_with_retry(
724-
pending_tool_calls,
725-
client,
726-
model_id,
727-
round_num + 1
728-
)
721+
if pending_tool_calls:
722+
if allow_more_tools:
723+
log_debug(f"Processing additional tools (round {round_num + 1})")
724+
if follow_up_response: self.messages.append({"role": "assistant", "content": follow_up_response})
725+
726+
return self._process_tool_calls_with_retry(
727+
pending_tool_calls,
728+
client,
729+
model_id,
730+
round_num + 1
731+
)
732+
else:
733+
# Reached MAX_TOOL_ROUNDS - ask user if they want to continue
734+
console.print()
735+
console.print(f"[{COLORS['warning']}]Reached {MAX_TOOL_ROUNDS} tool rounds. The task may not be complete.[/]")
736+
console.print(f"[{COLORS['muted']}]Continue with {MAX_TOOL_ROUNDS} more rounds? (y/n): [/]", end="")
737+
738+
try:
739+
user_choice = input().strip().lower()
740+
if user_choice in ['y', 'yes', 's', 'si', 'sí']:
741+
log_debug(f"User approved continuation for {MAX_TOOL_ROUNDS} more rounds")
742+
if follow_up_response: self.messages.append({"role": "assistant", "content": follow_up_response})
743+
744+
return self._process_tool_calls_with_retry(
745+
pending_tool_calls,
746+
client,
747+
model_id,
748+
round_num=1 # Reset counter
749+
)
750+
else:
751+
console.print(f"[{COLORS['muted']}]Stopping tool execution.[/]")
752+
except (EOFError, KeyboardInterrupt):
753+
console.print(f"\n[{COLORS['muted']}]Stopping tool execution.[/]")
729754

730755
return follow_up_response
731756

static-api/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "0.0.0.35"
2+
"version": "0.0.0.36"
33
}

0 commit comments

Comments
 (0)