Skip to content

Fix(logging) guard registration logs#15

Merged
St0rmz1 merged 3 commits intomainfrom
fix/guard-registration-logs
Apr 23, 2026
Merged

Fix(logging) guard registration logs#15
St0rmz1 merged 3 commits intomainfrom
fix/guard-registration-logs

Conversation

@St0rmz1
Copy link
Copy Markdown
Collaborator

@St0rmz1 St0rmz1 commented Apr 22, 2026

Summary

Guards the three "Registered …" info lines in register() behind a module-scoped registrationLogged flag so they fire at most once per process. Without this guard OpenClaw's plugin loader re-invokes register(api) once per distinct loadOpenClawPlugins cacheKey (gateway startup, provider discovery, metadata registry, web-fetch/web-search runtimes, etc.), producing ~44 redundant log lines per KiloClaw boot.

Background

Investigation traced the log spam to openclaw/src/plugins/loader.ts:loadOpenClawPlugins, which is called from many distinct code paths (gateway startup, CLI metadata, provider discovery, web-fetch/web-search runtimes, metadata-registry-loader, status, etc.). Each call with a different cacheKey builds a fresh registry and invokes every plugin's register(api) again. Our three unconditional api.logger.info?.(...) calls therefore fired ~15 times per process.

The plugin's tool factory ((toolCtx) => ({...})) re-running per tool-collection event was a known, documented behavior — but the three info lines were in the outer register(), not in the factory, so that context was misleading.

Scope

  • Logging only. api.registerTool(...) and api.registerCommand(...) still run on every register() call — intentional, because each loadOpenClawPlugins pass builds its own registry and the plugin must register into every one to be visible in that context.
  • No behavior change for users. Only reduces gateway log noise.

Changes

  • index.ts: added module-scoped let registrationLogged = false and wrapped the three info log calls in a first-time guard. Comment explains why register() runs multiple times and why only logging is gated.
  • CHANGELOG.md: [Unreleased] → Fixed entry describing the spam root cause and the guard.

Test plan

  • bun run typecheck — passes
  • bun run format:check (on edited files) — passes
  • bun test — 54/54 pass
  • Verify in a KiloClaw boot that the three "Registered …" lines appear exactly once (not ~15×).

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented Apr 22, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • CHANGELOG.md
  • index.ts

Reviewed by gpt-5.4-20260305 · 82,254 tokens

@St0rmz1 St0rmz1 merged commit 627864b into main Apr 23, 2026
7 checks passed
@St0rmz1 St0rmz1 deleted the fix/guard-registration-logs branch April 23, 2026 13:19
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.

2 participants