fix: log hook task exceptions instead of silently discarding them#1852
fix: log hook task exceptions instead of silently discarding them#1852iiitutu wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b27dc2c81
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| 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: %s", t.exception()) |
There was a problem hiding this comment.
Replace
%s placeholder in hook error log
logger here is Loguru (used throughout this repo with {} formatting), so logger.error("Hook failed: %s", t.exception()) logs the literal %s and drops the exception details. When a hook task fails, operators only see a generic message and still lose the actual error text, which defeats the purpose of this fix for debugging failed hooks (the same pattern appears in the other updated callbacks in this commit).
Useful? React with 👍 / 👎.
Hook tasks were using add_done_callback with a lambda that called t.exception() but never logged it, causing failures to be silently ignored. Now exceptions are properly logged via logger.error.
5b27dc2 to
a916c27
Compare
Summary
lambda t: t.exception() if not t.cancelled() else Nonewith proper error logging vialogger.errorProblem
Hook tasks used
add_done_callbackwith a lambda that calledt.exception()but never logged the result, causing hook failures to be silently ignored and making debugging extremely difficult.Solution
Changed the callback to properly log exceptions:
Files Modified
src/kimi_cli/soul/kimisoul.py(3 locations)src/kimi_cli/soul/toolset.py(2 locations)src/kimi_cli/subagents/runner.py(1 location)src/kimi_cli/hooks/engine.py(1 location)