Skip to content

improve(telegram): cut cold channel setup import latency - #122955

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-telegram-setup-entry
Aug 13, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-telegram-setup-entry

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators running openclaw channels add telegram would pay for Telegram's full runtime graph during a cold setup-only load. The same import leak dominated src/commands/channels.add.test.ts: main CI run 31657034715 spent 81.7s in the file and 79.5s in the Telegram --use-env case, making checks-node-compact-small-8 the slowest lane at 6.6 minutes.

Why This Change Was Made

Telegram now composes one canonical setup-safe plugin base containing the existing metadata, setup wizard, setup contract, capabilities, config schema, account config behavior, reload rules, and secret declarations. The full runtime plugin reuses that base and adds commands, Doctor, and security; the setup entry never imports those runtime-only surfaces.

The refactor also replaces three broad SDK imports with existing narrow seams: secret-provider-alias, secret-input, and a packaged-private channel-config-ui-hints entrypoint. This keeps the plugin boundary intact without promoting a new public SDK API.

User Impact

Cold openclaw channels add telegram setup lookup is materially faster while Telegram setup UX, configuration validation, credential handling, secrets, and full runtime behavior remain unchanged.

Evidence

AI-assisted change; final Codex autoreview was clean with no accepted/actionable findings.

Import profiling before the fix:

  • Bundled setup loader: 78,667.7ms (sourceLoaderCallMs=78,610.6), 2,199 Jiti-transformed modules.
  • The broad openclaw/plugin-sdk/provider-auth edge from account-inspect.ts opened 1,347 modules by itself.
  • Top module transform costs: src/agents/harness/registry.ts 131.326ms; packages/ai/dist/reasoning-tag-text-partitioner-*.mjs 104.563ms; src/plugins/providers.ts 89.88ms; extensions/telegram/setup-plugin-api.ts 80.643ms; src/agents/auth-profiles/oauth-manager.ts 63.527ms; kysely/dist/index.js 62.038ms; src/agents/provider-request-config.ts 60.287ms; commander/lib/command.js 52.691ms; src/agents/auth-profiles/store.ts 51.968ms; src/plugins/provider-runtime.ts 50.784ms.

Before/after:

  • time node scripts/run-vitest.mjs src/commands/channels.add.test.ts: 110.00s wall / 104.63s Vitest before; 15.80s wall / 12.60s Vitest after in the uncontended patch run. While this work was in flight, fix(ci): prevent channel add command test timeout #122879 independently landed the test-only synthetic contract optimization on main; this PR now carries only the owner-boundary Telegram fix.
  • Cache-disabled real bundled Telegram setup lookup: 79,810.5ms before -> 7,016.5ms after (81.35s -> 7.98s process wall).

Commands and gates:

  • OPENCLAW_VITEST_IMPORT_DURATIONS=1 OPENCLAW_VITEST_PRINT_IMPORT_BREAKDOWN=1 node scripts/run-vitest.mjs src/commands/channels.add.test.ts — 32/32 passed in the measured patch run.
  • node scripts/run-vitest.mjs extensions/telegram/src/account-inspect.test.ts extensions/telegram/src/config-schema.test.ts extensions/telegram/src/setup-surface.test.ts extensions/telegram/src/shared.test.ts — 73/73 passed on Blacksmith Testbox.
  • node scripts/check-changed.mjs -- <changed files> — passed all typecheck, lint, SDK surface, package boundary, dead-code, and import-cycle gates on Blacksmith Testbox.
  • pnpm build — passed on Blacksmith Testbox in 4m59s; no INEFFECTIVE_DYNAMIC_IMPORT warning for touched modules. Run: https://github.com/openclaw/openclaw/actions/runs/31660977841
  • git diff --check — clean.

The requested broad node scripts/run-vitest.mjs extensions/telegram was attempted locally and on a credential-hydrated Testbox, but both runs exposed unrelated current-main runtime-test failures (ambient multi-agent AgentSelectionRequiredError, polling/webhook timeouts) and the broad run hit the no-output watchdog. The setup/config owner tests above are green; exact-head PR CI remains the clean-environment broad-suite authority.

@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram scripts Repository scripts size: L maintainer Maintainer-authored PR labels Aug 13, 2026
@steipete
steipete marked this pull request as ready for review August 13, 2026 02:58
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Aug 13, 2026
@clawsweeper

clawsweeper Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 13, 2026, 4:18 AM ET / 08:18 UTC.

ClawSweeper review

What this changes

The PR separates Telegram’s setup-only plugin surface from commands, Doctor, and security runtime behavior to reduce cold channels add telegram imports.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open: no blocking correctness defect was found, and current main still loads Telegram setup through the runtime-heavy shared base. Exact-head CI is still running, and the maintainer label requires a human landing decision.

Priority: P2
Reviewed head: 0e199d05a271279de9c4c60a0426421cd40da024
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has strong focused behavior evidence and a coherent owner-boundary split, pending normal exact-head CI completion.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR provides after-fix terminal profiling of a real bundled Telegram setup lookup and focused passing setup/config validation; redact environment-specific details in any future proof updates.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR provides after-fix terminal profiling of a real bundled Telegram setup lookup and focused passing setup/config validation; redact environment-specific details in any future proof updates.
Evidence reviewed 7 items Current main still takes the broad setup path: The setup entry still spreads the shared Telegram plugin base, which currently imports command UI, Doctor, and security behavior; therefore main has not yet incorporated this setup-only split.
Setup/runtime ownership boundary: The PR head defines the setup-safe base with metadata, setup contract, schema, config, and secrets, while the runtime base extends it with commands, Doctor, and security.
Caller requires the retained setup surface: The channel-add flow force-loads a setup-only plugin and passes its setup contract to account-configuration preparation, so retaining config, secrets, and setup contract on the setup base is the correct owner boundary.
Findings None None.
Security None None.

How this fits together

The channel-add command loads a setup-scoped Telegram plugin to collect credentials, validate config, and apply setup changes. Telegram’s full runtime plugin then supplies message commands, diagnostics, and security behavior after setup.

flowchart LR
  A[Channel add command] --> B[Setup plugin registry]
  B --> C[Telegram setup-safe base]
  C --> D[Wizard config and secrets]
  E[Telegram runtime entry] --> F[Runtime plugin additions]
  F --> G[Commands Doctor security]
  D --> H[Configured Telegram channel]
  G --> H
Loading

Decision needed

Question Recommendation
Should this maintainer-owned Telegram setup-boundary refactor land after the remaining exact-head checks are green? Land after exact-head CI: Accept the setup/runtime split after the remaining required checks validate the current head.

Why: The patch is technically coherent, but the maintainer label and author association require an explicit human landing judgment rather than automated cleanup.

Before merge

  • Resolve merge risk (P1) - Required exact-head CI is still in progress; merge only after the package-boundary, extension-config, and channel-runtime checks finish successfully.
Agent review details

Security

None.

PR surface

Source +9, Tests +1, Config +7, Other +2. Total +19 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 258 249 +9
Tests 1 2 1 +1
Docs 0 0 0 0
Config 2 7 0 +7
Generated 0 0 0 0
Other 2 2 0 +2
Total 13 269 250 +19

Review metrics

Metric Value Why it matters
Production versus test LOC production +267/-249 (net +18); tests +2/-1 The small production increase is the explicit setup/runtime owner split; most moved config behavior is deleted from the runtime-only module.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the setup-safe Telegram base once exact-head CI confirms the packaged-private SDK boundary and the retained setup contract on the current head.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the setup-safe Telegram base once exact-head CI confirms the packaged-private SDK boundary and the retained setup contract on the current head.

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

Yes: current main’s setup entry imports the broad shared base, and the PR supplies a concrete cache-disabled bundled-setup measurement plus focused command and plugin test commands.

Is this the best way to solve the issue?

Yes: keeping one canonical setup-safe base and extending it only for runtime behavior removes the import leak without changing Telegram’s setup contract or adding a parallel policy path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3b6e54041f18.

Labels

Label justifications:

  • P2: The PR improves a bounded cold Telegram setup and CI performance path without evidence of a current user-facing outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR provides after-fix terminal profiling of a real bundled Telegram setup lookup and focused passing setup/config validation; redact environment-specific details in any future proof updates.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides after-fix terminal profiling of a real bundled Telegram setup lookup and focused passing setup/config validation; redact environment-specific details in any future proof updates.

Evidence

What I checked:

  • Current main still takes the broad setup path: The setup entry still spreads the shared Telegram plugin base, which currently imports command UI, Doctor, and security behavior; therefore main has not yet incorporated this setup-only split. (extensions/telegram/src/channel.setup.ts:9, 3b6e54041f18)
  • Setup/runtime ownership boundary: The PR head defines the setup-safe base with metadata, setup contract, schema, config, and secrets, while the runtime base extends it with commands, Doctor, and security. (extensions/telegram/src/setup-plugin.ts:11, 0e199d05a271)
  • Caller requires the retained setup surface: The channel-add flow force-loads a setup-only plugin and passes its setup contract to account-configuration preparation, so retaining config, secrets, and setup contract on the setup base is the correct owner boundary. (src/commands/channels/add.ts:191, 3b6e54041f18)
  • Narrow SDK imports preserve the prior contracts: The narrow secret-provider alias is the same export previously exposed by provider-auth, and secret-input re-exports the same secret coercion helpers previously imported through the runtime barrel. (src/plugin-sdk/secret-provider-alias.ts:8, 3b6e54041f18)
  • Private packaged boundary is declared consistently: The new UI-hint subpath is added to the SDK entrypoint list, marked private-local-only, mapped for extension package-boundary typechecking, and excluded from published declarations like neighboring private paths. (package.json:955, 0e199d05a271)
  • Feature provenance: The shared setup-base arrangement dates to the bundled channel setup-contract refactor, providing the architectural baseline this PR splits into setup-safe and runtime-only pieces. (extensions/telegram/src/shared.ts:134, 9e4381eb1c8c)

Likely related people:

  • steipete: Authored the prior bundled setup-contract refactor and the current setup/runtime split. (role: introduced the shared setup-base arrangement and recent area contributor; confidence: high; commits: 9e4381eb1c8c, 725fe96bd718, 0e199d05a271; files: extensions/telegram/src/shared.ts, extensions/telegram/src/channel.setup.ts, extensions/telegram/src/setup-plugin.ts)
  • Ayaan Zaidi: The Telegram account-inspection path retained by the split was recently maintained in the default-routing fix. (role: recent account-inspection contributor; confidence: medium; commits: 13613ecaf10f; files: extensions/telegram/src/account-inspect.ts, extensions/telegram/src/config-adapter.ts)
  • Jesse Merhi: Introduced the channel-owned setup-contract architecture consumed by the channel-add caller and preserved by this refactor. (role: setup-contract origin contributor; confidence: medium; commits: 4a2a6008091d; files: extensions/telegram/src/setup-core.ts, src/commands/channels/add.ts)

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 (4 earlier review cycles)
  • reviewed 2026-08-13T03:04:37.460Z sha 1a25c15b3d25f5883db5194d9f2613e57ab1d6c0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T03:16:01.087Z sha 6ac5958311393b5fbf1d1d84bc2790fcbe380a3b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T04:19:30.772Z sha f31c880104b5df18af251bcf280321efebb00fc9 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T06:23:31.486Z sha 640743aad6f594a8e41256e6d6def58dde6de51c :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 13, 2026
@steipete
steipete force-pushed the steipete/perf-telegram-setup-entry branch from 6ac5958 to f31c880 Compare August 13, 2026 04:13
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 13, 2026
@steipete
steipete force-pushed the steipete/perf-telegram-setup-entry branch from f31c880 to 640743a Compare August 13, 2026 06:17
@steipete steipete closed this Aug 13, 2026
@steipete steipete reopened this Aug 13, 2026
@steipete
steipete force-pushed the steipete/perf-telegram-setup-entry branch from 640743a to 0e199d0 Compare August 13, 2026 08:11
@steipete
steipete merged commit ccc1920 into main Aug 13, 2026
275 of 279 checks passed
@steipete
steipete deleted the steipete/perf-telegram-setup-entry branch August 13, 2026 08:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
…2955)

* perf(telegram): keep setup entry on light graph

* fix(plugin-sdk): complete private UI hint boundaries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram extensions: xai maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L 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