Skip to content

pi slow startup #2753

Closed
Closed

Description

@ilkerhk

Causing about 2 - 3 seconds slow startup in pi and omp.

Below is prepared by agent itself.

~/.pi/agent/extensions/rtk.ts and ~/.omp/agent/extensions/rtk.ts does a runtime value import:

import { isToolCallEventType } from "@earendil-works/pi-coding-agent"

This resolves to the package barrel (dist/index.js), which re-exports the entire agent core — a ~9.2 MB module graph. bun must parse and evaluate that whole graph at extension load just to obtain one function.

  • value import from barrel
  • type-only / no runtime import

So the import costs avoidable startup time. Disabling the extension entirely is what made startup noticeably faster.

Root cause: isToolCallEventType is trivial — return event.toolName === toolName (dist/core/extensions/types.js:42). Pulling the full barrel for it is unnecessary.

Fix: drop the value import and inline the check. import type { ExtensionAPI } stays (erased at transpile, zero runtime cost).

// remove: import { isToolCallEventType } from "@earendil-works/pi-coding-agent"
// change: if (!isToolCallEventType("bash", event)) return
// to: if (event.toolName !== "bash") return

Behaviorally identical; startup drops back to baseline.

Note: a subpath import (.../core/extensions) is not a viable al

Note: a subpath import (.../core/extensions) is not a viable alternative — the package's exports map declares only ".", so that specifier fails to resolve (Cannot find module), and even if it resolved, that subpath barrel re-exports loader.js/runner.js . Inlining the comparison is the only clean fix.

sed -i
-e '/^import { isToolCallEventType }/d'
-e 's/if (!isToolCallEventType("bash", event)) return/if (event.toolName !== "bash") return/'
"$target"

Activity

  1. added
    bug
    good first issue
    on Jun 30, 2026
  2. pszymkowiak commented on Jun 30, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 88%

    Summary

    Slow startup (2-3s) in pi/omp caused by a full barrel import of a ~9.2MB module just to use one trivial function; fix is to inline the comparison and remove the value import.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • ~/.pi/agent/extensions/rtk.ts
    • ~/.omp/agent/extensions/rtk.ts

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. durkagiri21-ship-it commented on Jul 5, 2026

    @durkagiri21-ship-it

    Hi @ilkerhk, I'd like to work on this issue. Can you assign it to me?

    I'll replace the runtime import with an inline check as suggested.

  4. ilkerhk commented on Jul 5, 2026

    @ilkerhk
    Author

    @durkagiri21-ship-it
    you can ask maintainers for the assignment.

  5. durkagiri21-ship-it commented on Jul 5, 2026

    @durkagiri21-ship-it

    @ilkerhk Thanks for the clarification!

    @aeppling @KuSh Hi, I'd like to work on this issue. Could you please assign it to me?

    I'll implement the fix as described: remove the runtime import and inline the event.toolName check to reduce startup time.

  6. KuSh commented on Jul 5, 2026

    @KuSh
    Collaborator

    No need for assignment, if there's no PR already feel free to contribute

  7. durkagiri21-ship-it commented on Jul 5, 2026

    @durkagiri21-ship-it

    Checked the codebase. No runtime import found in:

    1. hooks/pi/rtk.ts
    2. hooks/opencode/rtk.ts
    3. Searched entire repo with from ['"]runtime['"] regex - no results

    Seems this was already fixed in a previous commit. Closing this issue.

    If I'm looking in the wrong place, please point me to the correct file.

  8. KuSh commented on Jul 5, 2026

    @KuSh
    Collaborator

    It seems to still be there

  9. imzza commented on Jul 26, 2026

    @imzza

    I also noticed that Pi has become much slower, and its startup time is even worse than that of Codex or OpenCode.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:performancebuggood first issuepriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions