@@ -5,7 +5,7 @@ use serde_json::{Value, json};
55use crate :: {
66 Align , CodexGroup , CodexModelUsage , CodexServiceTier , CodexTimestampedUsage , CodexUsageBucket ,
77 Color , PricingMap , Result , SimpleTable , attach_unpriced_models,
8- cli:: { AgentReportKind , SharedArgs } ,
8+ cli:: { AgentReportKind , CostMode , SharedArgs } ,
99 color, format_breakdown_model_label, format_currency, format_models_multiline, format_number,
1010 json_float, missing_pricing_model_for_token_total, print_box_title,
1111 print_missing_pricing_warnings_for_models, sanitize_terminal_text,
@@ -18,13 +18,16 @@ pub(super) fn report_from_groups(
1818 kind : AgentReportKind ,
1919 pricing : & PricingMap ,
2020 speed : CodexSpeedPolicy ,
21+ mode : CostMode ,
2122) -> Value {
2223 let rows = groups
2324 . iter ( )
24- . map ( |( period, group) | group_json ( period, group, kind, pricing, speed) )
25+ . map ( |( period, group) | group_json ( period, group, kind, pricing, speed, mode ) )
2526 . collect :: < Vec < _ > > ( ) ;
2627 let mut totals = totals_json ( groups. values ( ) , pricing, speed) ;
27- attach_unpriced_models ( & mut totals, codex_missing_pricing_models ( groups, pricing) ) ;
28+ if mode != CostMode :: Display {
29+ attach_unpriced_models ( & mut totals, codex_missing_pricing_models ( groups, pricing) ) ;
30+ }
2831 json ! ( {
2932 rows_key( kind) : rows,
3033 "totals" : totals,
@@ -55,6 +58,7 @@ fn group_json(
5558 kind : AgentReportKind ,
5659 pricing : & PricingMap ,
5760 speed : CodexSpeedPolicy ,
61+ mode : CostMode ,
5862) -> Value {
5963 let cost = calculate_group_cost ( group, pricing, speed) ;
6064 let input_tokens = non_cached_input_tokens (
@@ -67,7 +71,7 @@ fn group_json(
6771 . iter ( )
6872 . map ( |( model, usage) | {
6973 let mut value = model_usage_json ( usage) ;
70- if codex_model_missing_pricing ( model, usage, pricing) {
74+ if mode != CostMode :: Display && codex_model_missing_pricing ( model, usage, pricing) {
7175 value[ "missingPricing" ] = json ! ( true ) ;
7276 }
7377 ( model. clone ( ) , value)
@@ -665,6 +669,7 @@ mod tests {
665669 AgentReportKind :: Daily ,
666670 & PricingMap :: default ( ) ,
667671 CodexSpeedPolicy :: Forced ( CodexServiceTier :: Standard ) ,
672+ CostMode :: Calculate ,
668673 ) ;
669674 assert_eq ! (
670675 report[ "totals" ] [ "unpricedModels" ] ,
@@ -700,6 +705,7 @@ mod tests {
700705 AgentReportKind :: Daily ,
701706 & pricing,
702707 CodexSpeedPolicy :: Forced ( CodexServiceTier :: Fast ) ,
708+ CostMode :: Calculate ,
703709 ) ;
704710 assert_eq ! ( report[ "totals" ] [ "costUSD" ] , 0.0 ) ;
705711 assert ! (
@@ -737,11 +743,41 @@ mod tests {
737743 AgentReportKind :: Daily ,
738744 & pricing,
739745 CodexSpeedPolicy :: Forced ( CodexServiceTier :: Standard ) ,
746+ CostMode :: Calculate ,
740747 ) ;
741748 assert ! ( report[ "totals" ] [ "costUSD" ] . as_f64( ) . unwrap( ) > 0.0 ) ;
742749 assert ! ( report[ "totals" ] . get( "unpricedModels" ) . is_none( ) ) ;
743750 }
744751
752+ #[ test]
753+ fn display_mode_omits_missing_pricing_metadata ( ) {
754+ let mut group = CodexGroup :: default ( ) ;
755+ group. models . insert (
756+ "gpt-unknown-preview" . to_string ( ) ,
757+ CodexModelUsage {
758+ input_tokens : 100 ,
759+ total_tokens : 100 ,
760+ ..CodexModelUsage :: default ( )
761+ } ,
762+ ) ;
763+ let groups = BTreeMap :: from ( [ ( "2026-08-20" . to_string ( ) , group) ] ) ;
764+
765+ let report = report_from_groups (
766+ & groups,
767+ AgentReportKind :: Daily ,
768+ & PricingMap :: default ( ) ,
769+ CodexSpeedPolicy :: Forced ( CodexServiceTier :: Standard ) ,
770+ CostMode :: Display ,
771+ ) ;
772+
773+ assert ! ( report[ "totals" ] . get( "unpricedModels" ) . is_none( ) ) ;
774+ assert ! (
775+ report[ "daily" ] [ 0 ] [ "models" ] [ "gpt-unknown-preview" ]
776+ . get( "missingPricing" )
777+ . is_none( )
778+ ) ;
779+ }
780+
745781 #[ test]
746782 fn non_cached_input_tokens_excludes_cache_reads_and_creation ( ) {
747783 assert_eq ! ( non_cached_input_tokens( 100 , 60 , 30 ) , 10 ) ;
0 commit comments