Skip to content

initialize_runtime(preprocess=True) runs full preprocess on every call #29

@u2135

Description

@u2135

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

  • README + examples explicitly state: call initialize_runtime() once per process before enabling intercepts; do not call from per-request handlers.
  • Consider API/docs clarification: e.g. split “bootstrap only” vs “bootstrap + preprocess”, or document initialize_runtime(preprocess=False) for advanced setups.
  • Optional follow-up issue: skip redundant preprocess when cache indicates preprocess already completed recently (product decision).

References

  • src/provably/handoff/client.pyinitialize_runtime
  • src/provably/handoff/_bootstrap.pyensure_bootstrap_cached

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions