core/cli+agent: run TTY confirms off the event loop

Max-rounds and destructive-tool prompts use asyncio.to_thread with
cancel paused on the main thread so multi-tool turns no longer look
like user cancel. Hooks may be sync or async.
This commit is contained in:
2026-07-15 09:41:32 +08:00
parent b80ebf783a
commit a7d9c9879b
10 changed files with 170 additions and 55 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ from .budget import DEFAULT_CONTEXT_MAX_CHARS, DEFAULT_TOOL_RESULT_MAX_CHARS
from .loop import DEFAULT_MAX_ROUNDS, run_chat_loop
if TYPE_CHECKING:
from collections.abc import AsyncIterator, Callable, Sequence
from collections.abc import AsyncIterator, Awaitable, Callable, Sequence
from plyngent.lmproto.openai_compatible.model import AnyChatMessage
from plyngent.memory import MemoryStore
@@ -17,7 +17,7 @@ if TYPE_CHECKING:
from .events import AgentEvent
from .tools import ToolRegistry
type LimitContinueHook = Callable[[str], bool]
type LimitContinueHook = Callable[[str], bool | Awaitable[bool]]
class ChatAgent: