feat(openclaw): drop redundant before_agent_start + add debugPerfTiming - #1477
Merged
Conversation
…fTiming Two unrelated-but-tiny openclaw improvements: - #1354: Stop registering `before_agent_start`. Its body only called `resolveAndCacheIdentity()` + emitted a debug log. The same identity resolution already happens in `before_dispatch` (earlier in the inbound path), `before_prompt_build` (re-resolves before recall, can infer senderId from prompt content), and `agent_end` (re-resolves before retain). Subscribing here was duplicate work on the hot path. - #1406: Add `debugPerfTiming?: boolean` plugin config flag (default false). When enabled, the plugin emits one info-level perf line per recall path and per retain path: perf: before_prompt_build hook_total=4200ms recall_main=3800ms source=fresh results=3 perf: agent_end hook_total=1200ms retain=1100ms outcome=ok bank=main messages=4 Lets users diagnose latency without patching the dist. The `source=fresh|reused` field reflects in-flight recall dedup; the `outcome=ok|queued|error` field reflects whether retain succeeded inline, was queued for retry, or failed outright. Also fixes a stale comment that referenced before_agent_start where the actual lifecycle stage is before_prompt_build.
OpenClaw's plugin loader runs configSchema validation with `additionalProperties: false`, so any PluginConfig field not declared in openclaw.plugin.json is silently rejected at config-set time. The manifest had drifted from the type: - retainMission, observationsMission (added in #1473) — never declared - debugPerfTiming (added earlier in this PR) — never declared - retainDocumentScope — pre-existing gap, declared now - enableKnowledgeTools — was in configSchema but missing from uiHints All five are now in both configSchema.properties and uiHints. Also fixed the bankMission description to match the corrected README from #1353 (only affects /reflect, not retain). Added a manifest.test.ts parity test that compares the type's keys to the manifest's declared keys and fails on either side of drift. This is the same class of bug as #1443 (whitelist drift) — having a test prevents the next round.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small, unrelated openclaw plugin changes bundled in one PR.
#1354 — drop
before_agent_startregistrationThe hook's body did nothing observable: a
resolveAndCacheIdentity()call and a debug log. The same identity resolution already happens in:before_dispatch— earlier in the inbound channel path, populates the cache.before_prompt_build— re-resolves before recall, can also infersenderIdfrom the raw prompt when ctx lacks it.agent_end— re-resolves before retain.Subscribing was duplicate work on the hot path. Removed the registration and the
\"agent_start\"member of thelogSkipOnceoperation union.Also fixed a stale comment in `stripMemoryTags` doc that referenced `before_agent_start` — the actual injection happens in `before_prompt_build`.
#1406 — opt-in `debugPerfTiming` flag
Adds `debugPerfTiming?: boolean` plugin config (default `false`). When on, the plugin emits one info-level perf line per recall path and per retain path:
```
perf: before_prompt_build hook_total=4200ms recall_main=3800ms source=fresh results=3
perf: agent_end hook_total=1200ms retain=1100ms outcome=ok bank=main messages=4
```
This lets users diagnose latency without patching the compiled dist (which is what the issue reporter resorted to). Specifics:
Test plan
Out of scope
Closes #1354
Closes #1406