Summary
Developers report initialize_runtime() taking ~8–9s and suspect it may run once per user request.
Current behavior (SDK)
ensure_bootstrap_cached() is idempotent per process (middleware/bootstrap work skipped after first success).
- With default
preprocess=True, initialize_runtime() always runs ensure_preprocess_intercept_padding (if POSTGRES_URL is set) and run_preprocess(...) on every invocation — there is no “only first call” guard for preprocess.
Impact
- Correct usage (once at worker startup): one-time cost is expected.
- Incorrect usage (per HTTP request / per agent turn): repeated multi-second preprocess even when bootstrap is cached.
Acceptance criteria
References
src/provably/handoff/client.py — initialize_runtime
src/provably/handoff/_bootstrap.py — ensure_bootstrap_cached
Summary
Developers report
initialize_runtime()taking ~8–9s and suspect it may run once per user request.Current behavior (SDK)
ensure_bootstrap_cached()is idempotent per process (middleware/bootstrap work skipped after first success).preprocess=True,initialize_runtime()always runsensure_preprocess_intercept_padding(ifPOSTGRES_URLis set) andrun_preprocess(...)on every invocation — there is no “only first call” guard for preprocess.Impact
Acceptance criteria
initialize_runtime()once per process before enabling intercepts; do not call from per-request handlers.initialize_runtime(preprocess=False)for advanced setups.References
src/provably/handoff/client.py—initialize_runtimesrc/provably/handoff/_bootstrap.py—ensure_bootstrap_cached