Verbose per-call LLM logging, raw request/response dumps, and end-of-log cost summary.
Docker Release / build-and-push (push) Successful in 1m13s
Docker Release / release (push) Skipped

- [LLM] line per call: stage, model, prompt size, output size, cost, parsed item counts
- LLM_RAW_DUMP: full prompt/response JSON per call under outputs/<job>/llm_raw/
- Cost block at tail of job.log (per-stage, per-model, cached vs live)
- Agent mode: reset llm cost counters per job; review finalization now teed into job.log + dumps
This commit is contained in:
2026-08-05 15:17:17 -05:00
parent f7e1b6bb7c
commit 7488cf68c5
7 changed files with 207 additions and 3 deletions
+15 -2
View File
@@ -20,7 +20,7 @@ from fastapi.responses import HTMLResponse, JSONResponse, Response
from fastapi.staticfiles import StaticFiles
import backend.jobs
from backend import config
from backend import config, llm
from backend.jobs import PIPELINE_MODES, create_job, get_job, _set
from backend.pipeline.pdf_processor import render_page_jpeg
from backend.review.feedback import decision_to_label, write_label
@@ -186,7 +186,20 @@ def save_review_decisions(job_id: str, payload: dict):
def _finalize_job(job_id: str, out_dir: str) -> None:
"""Background finalization: the ONE place the final report email may fire."""
try:
report = finalize_review(job_id, out_dir)
# Re-open the job's log tee + raw dump dir so the finalization LLM
# calls (clarification reruns, RFI drafting) land in job.log / llm_raw.
with backend.jobs.capture_job_output(job_id, out_dir):
print("\n=== Review finalization ===")
llm.reset_cost() # finalization-only cost attribution
report = finalize_review(job_id, out_dir)
cost = llm.get_cost()
backend.jobs._log_cost_summary({
"cost_usd": round(cost["usd"], 4),
"llm_calls": cost["calls"],
"cached_calls": cost.get("cached", 0),
"cost_by_stage": cost.get("by_stage", {}),
"models_used": cost.get("models", {}),
}, label="finalization")
except Exception as e:
try:
_set(job_id, status="finalization_error", error=str(e),