cli: fix limit prompt redundancy and line-break

This commit is contained in:
2026-07-29 01:38:04 +08:00
parent 60f9c9b56d
commit 39ecd55ddd
2 changed files with 17 additions and 6 deletions
+1 -1
View File
@@ -491,7 +491,7 @@ async def run_chat_loop( # noqa: C901, PLR0912 — multi-phase tool loop
continue
return
reason = f"tool loop reached {allowance} rounds (used {rounds_used})"
reason = f"tool loop limit reached ({allowance} rounds)"
if on_limit is not None and await _call_on_limit(on_limit, reason):
yield MaxRoundsEvent(rounds=allowance, continued=True)
allowance += max_rounds
+16 -5
View File
@@ -98,9 +98,17 @@ def _echo_tool_confirm(name: str, reason: str) -> None:
backend.echo()
def _echo_continue_limit(reason: str) -> None:
"""Echo the limit reason as a standalone line (not jammed into a confirm prompt)."""
backend = get_prompt_backend()
backend.secho(f"[limit] {reason}", fg="yellow")
backend.echo()
def _prompt_continue_limit_sync(reason: str) -> bool:
try:
return confirm(f"[limit] {reason}\nRaise limit and continue?", default=True)
_echo_continue_limit(reason)
return confirm("Raise limit and continue?", default=True)
except NonInteractiveError:
return False
@@ -114,10 +122,13 @@ def prompt_continue_limit(reason: str) -> bool:
async def prompt_continue_limit_async(reason: str) -> bool:
"""Async variant: confirm off the event loop so the turn is not cancelled."""
try:
return await confirm_async(
f"[limit] {reason}\nRaise limit and continue?",
default=True,
)
from plyngent.prompting import run_prompt_async
def _run() -> bool:
_echo_continue_limit(reason)
return confirm("Raise limit and continue?", default=True)
return await run_prompt_async(_run)
except NonInteractiveError:
return False