fix: register hooks at createOpikService() time to prevent zero traces#62
fix: register hooks at createOpikService() time to prevent zero traces#62saskinosie wants to merge 1 commit intocomet-ml:mainfrom
Conversation
The OpenClaw gateway initializes its global hook runner once, right after register() returns. Any api.on() calls inside start() run after the runner is sealed and are silently ignored, so the plugin captures zero traces for every user. Fix: move all hook registrations (registerLlmHooks, registerToolHooks, registerSubagentHooks, tool_result_persist, agent_end) into the body of createOpikService() before the return statement. This way they run during register() and get picked up by the hook runner. Also adds projectName to client.trace() so traces route to the configured project rather than silently defaulting to "Default Project". Confirmed working on OpenClaw 2026.4.8, plugin v0.2.9.
|
@vincentkoc can you please review? |
|
Closing this as superseded. The hook-registration regression this PR targeted was fixed on Worth saying plainly: the diagnosis here was useful and materially pointed at the real failure mode. The close is about overlap and staleness, not about the report being wrong. |
|
Thanks for the review! Understood on the hook timing fix being covered by 0.2.10. One thing that's still missing on main, client.trace() in src/service/hooks/llm.ts doesn't include projectName, so traces silently route to "Default Project" instead of the configured project. Happy to open a focused PR for just that fix if you'd like. |
|
@saskinosie ill validate now and raise a new pr and merge/release if I am able to replicate the issue. |
|
@vincentkoc It looks like projectName is already in client.trace() on main now, so no new PR needed. Thanks for taking a look and for the quick turnaround on the fix! |
The OpenClaw gateway initializes its global hook runner once, right after register() returns. Any api.on() calls inside start() run after the runner is sealed and are silently ignored, so the plugin captures zero traces for every user.
Fix: move all hook registrations (registerLlmHooks, registerToolHooks, registerSubagentHooks, tool_result_persist, agent_end) into the body of createOpikService() before the return statement. This way they run during register() and get picked up by the hook runner.
Also adds projectName to client.trace() so traces route to the configured project rather than silently defaulting to "Default Project".
Confirmed working on OpenClaw 2026.4.8, plugin v0.2.9.
Fixes #48, #49 and #61
Additionally, #36 was closed back in March with PR #43. That fix added a
warning for invalid project names. The hook timing issue was still there
and this is what was actually causing it