Skip to content

fix: register hooks at createOpikService() time to prevent zero traces#62

Closed
saskinosie wants to merge 1 commit intocomet-ml:mainfrom
saskinosie:fix/hooks-registered-after-runner-sealed
Closed

fix: register hooks at createOpikService() time to prevent zero traces#62
saskinosie wants to merge 1 commit intocomet-ml:mainfrom
saskinosie:fix/hooks-registered-after-runner-sealed

Conversation

@saskinosie
Copy link
Copy Markdown

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

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.
@gidim
Copy link
Copy Markdown
Contributor

gidim commented Apr 10, 2026

@vincentkoc can you please review?

@gidim gidim requested a review from vincentkoc April 10, 2026 17:04
@vincentkoc
Copy link
Copy Markdown
Member

Closing this as superseded.

The hook-registration regression this PR targeted was fixed on main and released in @opik/opik-openclaw@0.2.10, and the repo has since moved forward with compatibility/e2e hardening on top of that. The branch is dirty against current main, so keeping it open is just duplicate maintenance now.

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.

@vincentkoc vincentkoc closed this Apr 21, 2026
@saskinosie
Copy link
Copy Markdown
Author

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.

@vincentkoc
Copy link
Copy Markdown
Member

@saskinosie ill validate now and raise a new pr and merge/release if I am able to replicate the issue.

@saskinosie
Copy link
Copy Markdown
Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Was gonna use you guys - unfortunately doesnt work for non-default agents

3 participants