Skip to content
Open
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 src/kimi_cli/hooks/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,11 @@ async def _dispatch_wire_hook(
# Run the callback in background so timeout applies to the
# full client round-trip, not just handle.wait().
hook_task: asyncio.Task[None] = asyncio.ensure_future(self._on_wire_hook(handle))
hook_task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
hook_task.add_done_callback(
lambda t: logger.error("Hook failed: {}", t.exception())
if not t.cancelled() and t.exception()
else None
)
try:
return await asyncio.wait_for(handle.wait(), timeout=timeout)
except TimeoutError:
Expand Down
18 changes: 15 additions & 3 deletions src/kimi_cli/soul/kimisoul.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,11 @@ async def _agent_loop(self) -> TurnOutcome:
),
)
)
_hook_task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
_hook_task.add_done_callback(
lambda t: logger.error("Hook failed: {}", t.exception())
if not t.cancelled() and t.exception()
else None
)
# break the agent loop
raise

Expand Down Expand Up @@ -805,7 +809,11 @@ async def _append_notification(view: NotificationView) -> None:
),
)
)
_hook_task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
_hook_task.add_done_callback(
lambda t: logger.error("Hook failed: {}", t.exception())
if not t.cancelled() and t.exception()
else None
)

await self._runtime.notifications.deliver_pending(
"llm",
Expand Down Expand Up @@ -1044,7 +1052,11 @@ async def _compact_with_retry() -> CompactionResult:
),
)
)
_hook_task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
_hook_task.add_done_callback(
lambda t: logger.error("Hook failed: {}", t.exception())
if not t.cancelled() and t.exception()
else None
)

@staticmethod
def _is_retryable_error(exception: BaseException) -> bool:
Expand Down
10 changes: 8 additions & 2 deletions src/kimi_cli/soul/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ async def _call():
)
)
_hook_task.add_done_callback(
lambda t: t.exception() if not t.cancelled() else None
lambda t: logger.error("Hook failed: {}", t.exception())
if not t.cancelled() and t.exception()
else None
)
return ToolResult(
tool_call_id=tool_call.id,
Expand Down Expand Up @@ -240,7 +242,11 @@ async def _call():
),
)
)
_hook_task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
_hook_task.add_done_callback(
lambda t: logger.error("Hook failed: {}", t.exception())
if not t.cancelled() and t.exception()
else None
)

return ToolResult(tool_call_id=tool_call.id, return_value=ret)

Expand Down
6 changes: 5 additions & 1 deletion src/kimi_cli/subagents/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ async def run(self, req: ForegroundRunRequest) -> ToolReturnValue:
),
)
)
_hook_task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
_hook_task.add_done_callback(
lambda t: logger.error("Hook failed: {}", t.exception())
if not t.cancelled() and t.exception()
else None
)
except asyncio.CancelledError:
self._store.update_instance(agent_id, status="killed")
output_writer.stage("cancelled")
Expand Down
Loading