Skip to content

perf(agents): classify allowlists without intermediate sets - #138392

Merged
steipete merged 4 commits into
mainfrom
codex/perf-sep04-tool-allowlist-classification
Sep 6, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/perf-sep04-tool-allowlist-classification

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Tool availability checks add avoidable work to agent turns with layered allowlists. Separately, a loaded channel plugin without messaging hooks can receive fallback grammar and resolve the wrong parent session.

Why This Change Was Made

Populate the final classification Sets directly, remove the redundant policy round-trip through classification, and convert already-unique declaration Sets into fresh arrays. Each layer still reads current declarations, preserving callback-driven changes, iterator order, warning deduplication, frozen policies, matching and tool identity. No new cache, configuration, dependency or persistent state is introduced.

The separate conversation repair makes loaded-plugin presence the ownership boundary for bundled fallback, including when the plugin omits messaging. Production changes total −12 lines; tests total +71.

User Impact

Operators retain the same allow/deny decisions and diagnostics with less duplicate preparation. Loaded channel plugins retain ownership of conversation parsing. The measured benefit varies by workload; this does not establish a general Gateway/model-turn, startup, memory or tail-latency improvement.

Evidence

Current candidate validation: 123 owner/sibling cases, 347 caller cases, a full mapped build, 32 changed-check stages, and two managed review passes without actionable findings. The previously failing threaded-session model-override case passes in the current caller group.

Fresh measurement uses base 13e1b10 with the same conversation repair in both variants. Four fresh B0/C0/C1/B1 hosts execute the complete applyToolPolicyPipeline: 6,560 calls, including eight callback/iterator/error controls, and 384 batch means. All returned tool values and warnings are retained, with input-identity checks; return references are checked again after later calls. The common batch loop includes indexed reference retention; snapshotting and durable writes occur outside its timer. Batch-end snapshots do not claim to capture transient mutations later undone.

Observed median batch-mean changes:

Workload Forward Reverse
No policy −5.48% −10.19%
Core-only −1.77% +4.11% (+0.619 µs)
One mixed layer −9.25% −4.50%
Three mixed layers −8.65% −2.88%
Eight mixed layers −16.48% −9.60%
Empty declarations / cached warning −10.96% −10.89%

All 20 adverse comparisons are retained below. “Warm” is the warm-call median; “maximum” is the largest of 16 batch means, not a population-tail estimate.

Surface Forward adverse changes Reverse adverse changes
No policy First +15.78%; maximum +48.30% Maximum +3.13%
Core-only Maximum +108.16% First +2.26%; median +4.11%; maximum +253.54%
One mixed layer Warm +6.84% First +0.40%; warm +2.19%
Three mixed layers First +2.27% First +2.51%; maximum +37.10%
Eight mixed layers Maximum +12.56% Maximum +4.02%
Empty declarations Maximum +55.36% Warm +24.97%; maximum +99.98%
Host — Import/setup +0.85%; user CPU +0.75%

There was no numerical pass threshold or favorable rerun. Host measurements include imports, capture, logging and controls. Declaration production is covered functionally, not separately timed. Independent numerical audit verified every return/control record and all 60 comparisons, including all 20 adverse results. Refreshed exact-head CI remains the landing requirement.

Earlier cbaa21e tests/measurements remain historical and are not reused as current-head proof. Historical Linux R1 had an incomplete RSS census; Linux R2 lacked cgroup preflight. Current macOS/Vitest 5 success neither establishes historical timeout causation nor substitutes for that missing Linux evidence.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 4, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 9:15 PM ET / September 6, 2026, 01:15 UTC.

ClawSweeper review

What this changes

The PR reduces allocation during tool-allowlist classification and prevents bundled conversation parsing from overriding a loaded plugin that omits messaging hooks.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main retains both the redundant allowlist preparation and the incorrect fallback condition. No actionable introduced defect was found; the related merged PR addresses a different problem.

Priority: P3
Reviewed head: 3ab0020a4f5c67c201bad26c708c686dafd9dde8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with relevant regression coverage and carefully qualified benchmark reporting; no blocking correctness finding remains.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the external-contributor gate, and no material authority change activates additional proof requirements. The body reports direct production-pipeline measurements; conversation regression coverage is supplemental test evidence, not a live-channel demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor gate, and no material authority change activates additional proof requirements. The body reports direct production-pipeline measurements; conversation regression coverage is supplemental test evidence, not a live-channel demonstration.
Evidence reviewed 9 items Introduced changes and checkout identity: The local checkout matches the pinned head. Raw parent inspection confirms the original head parents and the supplied test merge's base-then-head parent order. The introduced delta matches the supplied seven-file patch; whitespace validation passed and the checkout remained clean.
Allocation simplification preserves producer semantics: The declaration producer already accumulates plugin IDs and tool names in Sets. Spreading those Sets preserves uniqueness, insertion order, and fresh-array ownership. Classification retains normalization and per-layer iteration; its removed policy field only returned the unchanged input.
Filtering and callback contracts remain intact: The pipeline still expands and filters the original policy, preserves frozen allowlists, and reads declarations independently for each layer. Existing tests cover deny precedence, plugin-only restrictions, frozen policies and warning deduplication; the new case covers callback-driven declaration changes. Tests were inspected, not executed.
Findings None None.
Security None None.

How this fits together

Agent tool policies turn configured permissions and plugin declarations into available tools and diagnostics. Separately, channel conversation parsing turns session keys into thread and parent identities used by session lookup and model overrides.

flowchart TD
  A[Policies and plugin declarations] --> B[Allowlist classification]
  B --> C[Layered tool filtering]
  C --> D[Available tools and warnings]
  E[Channel session key] --> F{Loaded plugin present}
  F -->|Yes| G[Plugin hook or generic parsing]
  F -->|No| H[Bundled fallback or generic parsing]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -12, Tests +71. Total +59 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 33 45 -12
Tests 3 98 27 +71
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 131 72 +59

Review metrics

Metric Value Why it matters
Reported pipeline performance Eight-layer medians −16.48% / −9.60%; reverse core-only median +4.11% The retained adverse result keeps the measured benefit scoped to workload rather than implying a universal latency improvement.

Technical review

Best possible solution:

Keep classification allocation-light and preserve loaded-plugin grammar ownership while retaining existing filtering, diagnostics and pre-bootstrap fallback behavior.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: a loaded plugin without messaging hooks can still invoke bundled topic parsing on main and select the wrong parent. The added regression fixture isolates that condition; this review did not execute it.

Is this the best way to solve the issue?

Yes. Direct Set population preserves classification semantics, and checking loaded-plugin presence repairs the documented fallback boundary without adding configuration or a parallel API.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1d9ce1ac9ffa.

Labels

Label justifications:

  • P3: This is a bounded performance improvement with a narrow conversation-parser correction and no demonstrated urgent production regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor gate, and no material authority change activates additional proof requirements. The body reports direct production-pipeline measurements; conversation regression coverage is supplemental test evidence, not a live-channel demonstration.

Evidence

What I checked:

  • Introduced changes and checkout identity: The local checkout matches the pinned head. Raw parent inspection confirms the original head parents and the supplied test merge's base-then-head parent order. The introduced delta matches the supplied seven-file patch; whitespace validation passed and the checkout remained clean. (3ab0020a4f5c)
  • Allocation simplification preserves producer semantics: The declaration producer already accumulates plugin IDs and tool names in Sets. Spreading those Sets preserves uniqueness, insertion order, and fresh-array ownership. Classification retains normalization and per-layer iteration; its removed policy field only returned the unchanged input. (src/agents/tool-policy-declared-context.ts:140, 3ab0020a4f5c)
  • Filtering and callback contracts remain intact: The pipeline still expands and filters the original policy, preserves frozen allowlists, and reads declarations independently for each layer. Existing tests cover deny precedence, plugin-only restrictions, frozen policies and warning deduplication; the new case covers callback-driven declaration changes. Tests were inspected, not executed. (src/agents/tool-policy-pipeline.test.ts:673, 3ab0020a4f5c)
  • Conversation repair follows the documented contract: The channel SDK documentation assigns conversation grammar to the loaded plugin and describes session-key artifacts as pre-bootstrap fallbacks. The patch checks loaded-plugin presence while retaining canonical and legacy hooks and generic parsing. Its regression case distinguishes room:topic:42 from room as the parent of the leaf thread. Public docs: docs/plugins/sdk-channel-plugins.md. (docs/plugins/sdk-channel-plugins.md:389, 3ab0020a4f5c)
  • Current main still needs the repair: The affected production files are identical between the pinned base and fetched main. Main still tests absence of messaging rather than absence of the loaded plugin, and still constructs intermediate declaration Sets. (src/channels/plugins/session-conversation.ts:211, 1d9ce1ac9ffa)
  • Latest release retains the old implementation: Inspection of v2026.9.2 shows the old conversation fallback condition and intermediate allowlist Sets. The tag resolves to the supplied release SHA; this work is not already present in that release. (src/channels/plugins/session-conversation.ts:211, 3928bad9badf)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-04T16:41:47.592Z sha 7fa37f6 :: blocked before merge. :: none

@steipete
steipete requested review from a team as code owners September 6, 2026 01:02
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: 3ab0020a4f5c67c201bad26c708c686dafd9dde8

@github-actions github-actions Bot removed the dependencies-changed PR changes dependency-related files label Sep 6, 2026
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The refreshed seven-file head includes the current-main composition, full mapped build, 123 owner/sibling cases, 347 caller cases, all 32 changed checks, and a newly audited 6,560-call pipeline cohort. The two-file conversation repair has its own pre-fix regression; it is not claimed to explain the historical CI timeout. All current and historical performance qualifications remain in the body.

GitHub's normal branch update refreshed stale base metadata. Head 3ab0020a4f5c67c201bad26c708c686dafd9dde8 against main d85142c70935e793dc5818e5ac545bbb9cf72dd7 has exactly the same seven-file patch as the tested 13e1b10f composition. No measurement was rerun or rebound to a newer build. New exact-head CI must pass before landing.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit 56f121d into main Sep 6, 2026
178 checks passed
@steipete
steipete deleted the codex/perf-sep04-tool-allowlist-classification branch September 6, 2026 01:19
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* origin/main: (302 commits)
  test(gateway): preserve held-work close failures (#139593)
  refactor(exec): share package argument scanning (#139560)
  fix(audit): preserve sequence range validation before numeric decoding (#139587)
  fix(transcripts): retain capture ownership through failed cleanup (#139572)
  refactor(models): share selector reference traversal (#139571)
  perf(agents): classify allowlists without intermediate sets (#138392)
  chore(release): update appcast for 2026.9.2 (#139575)
  fix(ci): synchronize cloud retries and board widget input (#139506)
  fix(plugins): explain SDK incompatibilities after core updates (#139458)
  fix(voice-call): retain installed WebSocket behavior under Bun (#139567)
  test(text): consolidate literal sanitizer cases (#139579)
  test(gateway): observe native drain without a lint exception (#139576)
  test(memory): consolidate visibility fixtures without policy defaults (#139569)
  fix(ui): show shimmer skeletons while loading Control UI (#139525)
  test(qa): make cleanup child logging deterministic (#139566)
  test(cli): keep Unix socket fixtures within path limits (#139565)
  fix: avoid slow incognito key checks in large session stores (#139528)
  feat(macos): open Gateway windows from the Gateways menu (#139522)
  test(workshop): isolate marker casing fixture identities (#139554)
  fix(process): require cleanup evidence before releasing owned work (#139517)
  ...

# Conflicts:
#	scripts/release-check.ts
vincentkoc added a commit that referenced this pull request Sep 6, 2026
* commit '047587a542ce205ee78354fbd88ba8ec05c07844': (45 commits)
  chore(ui): refresh control ui locales (#139481)
  fix(slack): keep prototype-named emoji shortcodes intact (#136374)
  fix(gateway): deliver upgrade rejection responses under Bun (#139516)
  refactor(test): simplify catalog guards and fix native report fixture (#139496)
  fix(macos): prevent dashboard fixture loopback timeouts (#139556)
  fix(matrix): preserve selected reply targets inside threads (#139479)
  test(gateway): preserve held-work close failures (#139593)
  refactor(exec): share package argument scanning (#139560)
  fix(audit): preserve sequence range validation before numeric decoding (#139587)
  fix(transcripts): retain capture ownership through failed cleanup (#139572)
  refactor(models): share selector reference traversal (#139571)
  perf(agents): classify allowlists without intermediate sets (#138392)
  chore(release): update appcast for 2026.9.2 (#139575)
  fix(ci): synchronize cloud retries and board widget input (#139506)
  fix(plugins): explain SDK incompatibilities after core updates (#139458)
  fix(voice-call): retain installed WebSocket behavior under Bun (#139567)
  test(text): consolidate literal sanitizer cases (#139579)
  test(gateway): observe native drain without a lint exception (#139576)
  test(memory): consolidate visibility fixtures without policy defaults (#139569)
  fix(ui): show shimmer skeletons while loading Control UI (#139525)
  ...
vincentkoc added a commit that referenced this pull request Sep 6, 2026
* commit 'refs/openclaw/tasks/pr-135167-main': (2467 commits)
  refactor(ios): reuse shared integer conversion (#139581)
  fix(sessions): prevent database lock failures during reclamation (#139469)
  perf(test): reuse transforms within owned scheduler slots (#139553)
  test(agents): share sparse transcript input fixtures (#139589)
  chore(ui): refresh control ui locales (#139481)
  fix(slack): keep prototype-named emoji shortcodes intact (#136374)
  fix(gateway): deliver upgrade rejection responses under Bun (#139516)
  refactor(test): simplify catalog guards and fix native report fixture (#139496)
  fix(macos): prevent dashboard fixture loopback timeouts (#139556)
  fix(matrix): preserve selected reply targets inside threads (#139479)
  test(gateway): preserve held-work close failures (#139593)
  refactor(exec): share package argument scanning (#139560)
  fix(audit): preserve sequence range validation before numeric decoding (#139587)
  fix(transcripts): retain capture ownership through failed cleanup (#139572)
  refactor(models): share selector reference traversal (#139571)
  perf(agents): classify allowlists without intermediate sets (#138392)
  chore(release): update appcast for 2026.9.2 (#139575)
  fix(ci): synchronize cloud retries and board widget input (#139506)
  fix(plugins): explain SDK incompatibilities after core updates (#139458)
  fix(voice-call): retain installed WebSocket behavior under Bun (#139567)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…#138392)

* perf(agents): classify allowlists without intermediate sets

* perf(agents): simplify allowlist preparation and session fallback ownership
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant