From 39ecd55dddc1a2d766f4fc5a3ed773e79fcdd293 Mon Sep 17 00:00:00 2001 From: worldmozara Date: Wed, 29 Jul 2026 01:38:04 +0800 Subject: [PATCH] cli: fix limit prompt redundancy and line-break --- src/plyngent/agent/loop.py | 2 +- src/plyngent/cli/limits.py | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/plyngent/agent/loop.py b/src/plyngent/agent/loop.py index 351d49b..50213c6 100644 --- a/src/plyngent/agent/loop.py +++ b/src/plyngent/agent/loop.py @@ -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 diff --git a/src/plyngent/cli/limits.py b/src/plyngent/cli/limits.py index b987940..5c58f41 100644 --- a/src/plyngent/cli/limits.py +++ b/src/plyngent/cli/limits.py @@ -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