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:
@@ -69,7 +69,9 @@ class PRAutoBlogger_Cost_Tracker {
|
||||
/**
|
||||
* Log an API call with its token usage and estimated cost.
|
||||
*
|
||||
* Side effects: database insert into prab_generation_log.
|
||||
* Side effects: database insert into prab_generation_log. Consumes the
|
||||
* Request_Recorder stash (v0.20.0 / B1) into the row's request_json so
|
||||
* every chat call's input is persisted (retention-pruned after R days).
|
||||
*
|
||||
* @param int|null $post_id WordPress post ID (null during generation, set later).
|
||||
* @param string $stage Pipeline stage (see PRAutoBlogger_Stage_Display_Map).
|
||||
@@ -117,6 +119,7 @@ class PRAutoBlogger_Cost_Tracker {
|
||||
'estimated_cost' => $cost,
|
||||
'response_status' => $response_status,
|
||||
'error_message' => $error_message,
|
||||
'request_json' => PRAutoBlogger_Request_Recorder::consume(),
|
||||
'agent_role' => $agent_role ?? PRAutoBlogger_Stage_Display_Map::default_agent_role( $stage ),
|
||||
'prompt_version' => $this->resolve_prompt_version( $stage, $prompt_key ),
|
||||
'created_at' => current_time( 'mysql' ),
|
||||
|
||||
Reference in New Issue
Block a user