@@ -66,6 +66,7 @@ struct EvalFixtureDagContext {
6666 dag_config : EvalFixtureDagConfig ,
6767 comments : Vec < core:: Comment > ,
6868 warnings : Vec < String > ,
69+ cost_breakdowns : Vec < crate :: server:: cost:: CostBreakdownRow > ,
6970 verification_report : Option < EvalVerificationReport > ,
7071 agent_activity : Option < EvalAgentActivity > ,
7172 reproduction_summary : Option < EvalReproductionSummary > ,
@@ -82,6 +83,7 @@ enum EvalFixtureStageOutput {
8283 Review {
8384 comments : Vec < core:: Comment > ,
8485 warnings : Vec < String > ,
86+ cost_breakdowns : Vec < crate :: server:: cost:: CostBreakdownRow > ,
8587 verification_report : Option < EvalVerificationReport > ,
8688 agent_activity : Option < EvalAgentActivity > ,
8789 dag_traces : Vec < DagExecutionTrace > ,
@@ -99,6 +101,7 @@ enum EvalFixtureStageOutput {
99101 ReproductionValidation {
100102 reproduction_summary : Option < EvalReproductionSummary > ,
101103 warnings : Vec < String > ,
104+ cost_breakdowns : Vec < crate :: server:: cost:: CostBreakdownRow > ,
102105 } ,
103106 ArtifactCapture {
104107 artifact_path : Option < String > ,
@@ -112,6 +115,7 @@ impl EvalFixtureDagContext {
112115 dag_config,
113116 comments : Vec :: new ( ) ,
114117 warnings : Vec :: new ( ) ,
118+ cost_breakdowns : Vec :: new ( ) ,
115119 verification_report : None ,
116120 agent_activity : None ,
117121 reproduction_summary : None ,
@@ -147,6 +151,7 @@ impl EvalFixtureDagContext {
147151 reproduction_summary : self . reproduction_summary ,
148152 artifact_path : self . artifact_path ,
149153 failures : self . failures ,
154+ cost_breakdowns : self . cost_breakdowns ,
150155 dag_traces,
151156 } ,
152157 } )
@@ -409,9 +414,27 @@ fn spawn_stage(
409414 let repo_path = context. prepared . repo_path . clone ( ) ;
410415 let config = config. clone ( ) ;
411416 Ok ( async move {
417+ let generation_role = config. generation_model_role . as_str ( ) . to_string ( ) ;
418+ let generation_provider =
419+ config. inferred_provider_label_for_role ( config. generation_model_role ) ;
420+ let generation_model = config. generation_model_name ( ) . to_string ( ) ;
412421 let review_result =
413422 review_diff_content_raw ( & diff_content, config, & repo_path) . await ?;
423+ let cost_breakdowns = crate :: server:: cost:: review_cost_breakdowns (
424+ crate :: server:: cost:: CostBreakdownRequest {
425+ workload : "eval_generation" ,
426+ role : & generation_role,
427+ provider : generation_provider,
428+ model : & generation_model,
429+ prompt_tokens : review_result. total_prompt_tokens ,
430+ completion_tokens : review_result. total_completion_tokens ,
431+ total_tokens : review_result. total_tokens ,
432+ } ,
433+ "eval_verification" ,
434+ review_result. verification_report . as_ref ( ) ,
435+ ) ;
414436 Ok ( EvalFixtureStageOutput :: Review {
437+ cost_breakdowns,
415438 verification_report : convert_verification_report (
416439 review_result. verification_report ,
417440 ) ,
@@ -486,9 +509,27 @@ fn spawn_stage(
486509 . as_ref ( )
487510 . map ( build_reproduction_warnings)
488511 . unwrap_or_default ( ) ;
512+ let cost_breakdowns = reproduction_summary
513+ . as_ref ( )
514+ . and_then ( |summary| {
515+ ( summary. total_tokens > 0 ) . then ( || {
516+ crate :: server:: cost:: CostBreakdownRow :: new (
517+ "eval_auditing" ,
518+ summary. role . as_str ( ) ,
519+ summary. provider . clone ( ) ,
520+ summary. model . as_str ( ) ,
521+ summary. prompt_tokens ,
522+ summary. completion_tokens ,
523+ summary. total_tokens ,
524+ )
525+ } )
526+ } )
527+ . into_iter ( )
528+ . collect ( ) ;
489529 Ok ( EvalFixtureStageOutput :: ReproductionValidation {
490530 reproduction_summary,
491531 warnings,
532+ cost_breakdowns,
492533 } )
493534 }
494535 . boxed ( ) )
@@ -543,6 +584,7 @@ fn apply_stage_output(
543584 EvalFixtureStageOutput :: Review {
544585 comments,
545586 warnings,
587+ cost_breakdowns,
546588 verification_report,
547589 agent_activity,
548590 dag_traces,
@@ -551,6 +593,7 @@ fn apply_stage_output(
551593 context. total_comments = comments. len ( ) ;
552594 context. comments = comments;
553595 context. warnings = warnings;
596+ context. cost_breakdowns = cost_breakdowns;
554597 context. verification_report = verification_report;
555598 context. agent_activity = agent_activity;
556599 context. dag_traces = dag_traces;
@@ -586,10 +629,12 @@ fn apply_stage_output(
586629 EvalFixtureStageOutput :: ReproductionValidation {
587630 reproduction_summary,
588631 warnings,
632+ cost_breakdowns,
589633 } ,
590634 ) => {
591635 context. reproduction_summary = reproduction_summary;
592636 context. warnings . extend ( warnings) ;
637+ context. cost_breakdowns . extend ( cost_breakdowns) ;
593638 Ok ( ( ) )
594639 }
595640 (
0 commit comments