feat(coding-agent): improved Python startup performance with prelude caching and shared gateway mode

- Added Python prelude caching to improve startup performance by caching helper functions and module discovery results.
- Added OMP_DEBUG_STARTUP environment variable for detailed startup stage tracing across initialization pipeline.
- Changed Python kernel initialization to require shared gateway mode, removing support for local kernel gateway startup.
- Improved error handling in shared gateway acquisition with automatic retries on 5xx status codes.
- Added repro-stuck.ts script for reproducing and debugging rare CLI hang issues with Chrome DevTools integration.
- Added trace-loader.ts preload script for tracing module resolution during startup diagnostics.
This commit is contained in:
can1357
2026-02-04 05:02:28 +01:00
parent 395a606167
commit f41705ce3a
9 changed files with 464 additions and 176 deletions
@@ -8,6 +8,12 @@
*/
import * as os from "node:os";
import * as path from "node:path";
/** Conditional startup debug prints (stderr) when OMP_DEBUG_STARTUP is set */
const debugStartup = process.env.OMP_DEBUG_STARTUP
? (stage: string) => process.stderr.write(`[startup] ${stage}\n`)
: () => {};
import type { Settings } from "../config/settings";
import { clearCache as clearFsCache, cacheStats as fsCacheStats, invalidate as invalidateFs } from "./fs";
import type {
@@ -109,9 +115,12 @@ async function loadImpl<T>(
const results = await Promise.all(
providers.map(async provider => {
try {
debugStartup(`capability:${capability.id}:${provider.id}:start`);
const result = await provider.load(ctx);
debugStartup(`capability:${capability.id}:${provider.id}:done`);
return { provider, result };
} catch (error) {
debugStartup(`capability:${capability.id}:${provider.id}:error`);
return { provider, error };
}
}),