feat(verifier): Port/re-implement Quality Verifier functionality from the Python LIP
Reaserch transcript:
Found it. The feature is called the Quality Verifier (the circuit-breaker config still references its earlier codename "Angel" — see the quality_verifier_cooldown_seconds comment in config/config.example.yaml).
What it is
When enabled, every N eligible turns (quality_verifier_frequency, default 10) the proxy holds the main-model completion, calls a secondary verifier LLM (quality_verifier_model) with the conversation history so far, and asks it to audit the last completion. The verifier replies with exactly one of:
<status>NO_STEERING_NEEDED</status> → original output is returned
<steering>…</steering> → the proxy does an inline "recall" call of the main model with a private steering system message
It's off by default — enabled by setting quality_verifier_model (CLI --quality-verifier-model backend:model or YAML under session:).
Key functions
| Function |
Location |
QualityVerifierService.is_enabled() / should_run_verification() / should_run_for_request() — scheduling "every N turns" |
src/core/services/quality_verifier_service.py |
build_verification_messages() — builds the verifier request (prompt + sanitized/truncated session history + completion under audit) |
src/core/services/quality_verifier_service.py |
validate_quality_verifier_output_format() / maybe_retry_verifier_for_valid_xml() / build_invalid_format_retry_request() |
src/core/services/quality_verifier_service.py |
Circuit breaker: is_healthy() / report_success() / report_failure() |
src/core/services/quality_verifier_service.py |
run_quality_verifier_decision() — core decision flow (call verifier → parse verdict → steer/pass/fail-open) |
src/core/services/quality_verifier_orchestrator.py |
QualityVerifierStreamVerifier.verify_or_passthrough() — streaming path: buffers chunks, verifies, replays or issues inline recall |
src/core/services/backend_request_manager/quality_verifier_stream_verifier.py |
Turn ledger: _get/_set_quality_verifier_turn_count, reset_quality_verifier_eligible_turn_count() |
src/core/services/request_processor_service.py |
_extract_quality_verifier_config() |
src/core/services/backend_request_manager/streaming_response_handler.py |
Most important files
src/core/services/quality_verifier_service.py — the service itself (scheduling, message building, format validation, circuit breaker)
src/core/services/quality_verifier_orchestrator.py — run_quality_verifier_decision(), the actual verify-and-steer flow
src/core/services/backend_request_manager/quality_verifier_stream_verifier.py — streaming integration (verify_or_passthrough)
src/core/services/request_processor_service.py — eligible-turn counting/reset (the "every N turns" trigger)
src/core/services/quality_verifier_prompt_loader.py + config/prompts/quality_verifier_prompts/ — the verifier role prompt, steering template, tail reminder
src/core/services/quality_verifier_steering_messages.py — renders/injects the private steering system message for the recall call
src/core/di/registration_helpers/request_processing/_rp_backend_components.py + src/core/services/backend_request_manager_service.py — DI wiring into the request pipeline
config/config.example.yaml (session: section) and src/core/cli.py (_warn_if_quality_verifier_frequency_too_low) — configuration
docs/user_guide/features/quality-verifier.md — full documentation (also docs/quality-verifier-fractional-turns.md)
The "external LLM providing advice/steering" part is the verifier returning <steering> XML, and the "inline recall" mechanism (append_quality_verifier_steering_system_message) is how the main model actually gets steered on that same turn.
feat(verifier): Port/re-implement Quality Verifier functionality from the Python LIP
Reaserch transcript:
Found it. The feature is called the Quality Verifier (the circuit-breaker config still references its earlier codename "Angel" — see the
quality_verifier_cooldown_secondscomment inconfig/config.example.yaml).What it is
When enabled, every N eligible turns (
quality_verifier_frequency, default 10) the proxy holds the main-model completion, calls a secondary verifier LLM (quality_verifier_model) with the conversation history so far, and asks it to audit the last completion. The verifier replies with exactly one of:<status>NO_STEERING_NEEDED</status>→ original output is returned<steering>…</steering>→ the proxy does an inline "recall" call of the main model with a private steering system messageIt's off by default — enabled by setting
quality_verifier_model(CLI--quality-verifier-model backend:modelor YAML undersession:).Key functions
QualityVerifierService.is_enabled()/should_run_verification()/should_run_for_request()— scheduling "every N turns"src/core/services/quality_verifier_service.pybuild_verification_messages()— builds the verifier request (prompt + sanitized/truncated session history + completion under audit)src/core/services/quality_verifier_service.pyvalidate_quality_verifier_output_format()/maybe_retry_verifier_for_valid_xml()/build_invalid_format_retry_request()src/core/services/quality_verifier_service.pyis_healthy()/report_success()/report_failure()src/core/services/quality_verifier_service.pyrun_quality_verifier_decision()— core decision flow (call verifier → parse verdict → steer/pass/fail-open)src/core/services/quality_verifier_orchestrator.pyQualityVerifierStreamVerifier.verify_or_passthrough()— streaming path: buffers chunks, verifies, replays or issues inline recallsrc/core/services/backend_request_manager/quality_verifier_stream_verifier.py_get/_set_quality_verifier_turn_count,reset_quality_verifier_eligible_turn_count()src/core/services/request_processor_service.py_extract_quality_verifier_config()src/core/services/backend_request_manager/streaming_response_handler.pyMost important files
src/core/services/quality_verifier_service.py— the service itself (scheduling, message building, format validation, circuit breaker)src/core/services/quality_verifier_orchestrator.py—run_quality_verifier_decision(), the actual verify-and-steer flowsrc/core/services/backend_request_manager/quality_verifier_stream_verifier.py— streaming integration (verify_or_passthrough)src/core/services/request_processor_service.py— eligible-turn counting/reset (the "every N turns" trigger)src/core/services/quality_verifier_prompt_loader.py+config/prompts/quality_verifier_prompts/— the verifier role prompt, steering template, tail remindersrc/core/services/quality_verifier_steering_messages.py— renders/injects the private steering system message for the recall callsrc/core/di/registration_helpers/request_processing/_rp_backend_components.py+src/core/services/backend_request_manager_service.py— DI wiring into the request pipelineconfig/config.example.yaml(session:section) andsrc/core/cli.py(_warn_if_quality_verifier_frequency_too_low) — configurationdocs/user_guide/features/quality-verifier.md— full documentation (alsodocs/quality-verifier-fractional-turns.md)The "external LLM providing advice/steering" part is the verifier returning
<steering>XML, and the "inline recall" mechanism (append_quality_verifier_steering_system_message) is how the main model actually gets steered on that same turn.