You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3a8530f
Browse filesBrowse the repository at this point in the historyBrowse files
Reuse one LLM HTTP client across a whole monitor run
Performance improvement, not a new feature: runner::run_one_with (one
call per form) reached into llm::run_semantic_checks, which called
LlmClient::new() itself on every single call. LlmClient::new() builds
a fresh reqwest::Client, i.e. an empty connection pool - so a registry
of N forms with --llm enabled paid N separate DNS/TCP/TLS handshakes
to the exact same provider host (api.openai.com, api.anthropic.com,
...) instead of reusing one pool of keep-alive connections. This
compounds under --max-concurrent, where several of those handshakes
happen at once for no reason.
Fix: build the LlmClient once per test/monitor invocation (in main.rs,
right alongside the browser and HostPacer that are already built once
and shared) and thread it through run_one_with/run_semantic_checks as
Option<&LlmClient> instead of rebuilding it inside the per-form call.
Client-build failure (LlmClient::new only fails if the underlying TLS
backend can't initialize, essentially never in practice) is now
surfaced once via a single tracing::warn! instead of once per form,
and still degrades every form's LLM checks to a Warn rather than
failing the run - unchanged behavior, just not repeated pointlessly.
Verified with a mutation test: temporarily forced build_llm_client to
always return None regardless of input, confirmed the new unit test
(build_llm_client_is_none_when_disabled_and_some_when_enabled) failed
as predicted, then restored it and confirmed cargo test passes clean.
cargo fmt/clippy -D warnings clean, full suite green (153 tests).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments