Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Fixing Oh My Zsh Subshell Latency in Coding Agent CLI Runners

说明与用途

自动化编码代理在启动子 shell 时会加载 Oh My Zsh 的插件,导致延迟。通过在 ~/.zshrc 中添加早期退出 guard 并导出 AGENT_RUNNER,子 shell 启动时间从 680 ms 降至 14 ms。

问题

Autonomous coding agents spawn subshells that inherit Oh My Zsh initialization, causing significant latency per command.

结果

Subshell latency reduced from ~680 ms to ~14 ms per launch, cutting cumulative idle time in multi‑step agent workflows by over 30 seconds.

工作流

  • 1. Benchmark current subshell startup: time for i in {1..10}; do zsh -i -c exit; done
  • 2. Add guard at top of ~/.zshrc: if [[ -n "$AGENT_RUNNER" || $- != *i* ]]; then export PATH="$HOME/.local/bin:$PATH"; return 0; fi
  • 3. Configure agent runner to export AGENT_RUNNER=1 in its environment
  • 4. Verify reduced latency with the benchmark command

证据

10 spawns averaged 6.8 seconds (~680ms per shell).

来源

Subshell spin‑up immediately drops from ~680ms to ~14ms.

来源

  • 记录日期: 2026-10-07T20:41:20.282Z