Fixing Oh My Zsh Subshell Latency in Coding Agent CLI Runners
Описание и применение
Автономные агенты кода создают под‑шеллы, которые наследуют инициализацию Oh My Zsh, что приводит к задержкам. Добавив ранний выход в ~/.zshrc и экспортировав переменную AGENT_RUNNER, время запуска под‑шелла снизилось с 680 мс до 14 мс.
Задача
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