feat(B1): persist request_json on every chat LLM call via process-scoped recorder

The OpenRouter provider stashes the outgoing request BODY (never headers --
Authorization is built separately and build_body() copies only whitelisted
option keys) in the new PRAutoBlogger_Request_Recorder before dispatch;
Cost_Tracker::log_api_call() consumes it (consume-once) into
generation_log.request_json. All seven chat call sites covered with zero
call-site changes; error/timeout rows carry the request too. Retention
rides the existing prautoblogger_request_json_retention_days prune.

Unblocks M3 edit+rerun (stage inputs now exist) and makes the M2 dossier
raw-input trace real (QA seq 20 F1).

Agent-Session: engineer-prab-m3-20260612
This commit is contained in:
peptiderepo
2026-06-12 12:59:49 +00:00
parent 3b6a302f95
commit 1b31ef6396
5 changed files with 385 additions and 1 deletions

View File

@@ -78,6 +78,13 @@ class PRAutoBlogger_OpenRouter_Provider implements PRAutoBlogger_LLM_Provider_In
// reasoning token cap + completion headroom — lives in the builder.
$body = $builder->build_body( $messages, $model, $options );
// v0.20.0 (B1): stash the outgoing request body so the next
// log_api_call() persists it to generation_log.request_json.
// Only the BODY is recorded -- Authorization lives exclusively in
// build_headers()' return and can never reach the recorder.
// Recorded BEFORE dispatch so error/timeout rows carry it too.
PRAutoBlogger_Request_Recorder::record( $body );
// Whether the outgoing request has reasoning enabled — drives the
// empty-completion retry decision after parse.
$reasoning_active = isset( $body['reasoning'] ) && false !== ( $body['reasoning']['enabled'] ?? true );