diff --git a/workflowai/core/domain/run.py b/workflowai/core/domain/run.py index 1db9aed..fbf15ca 100644 --- a/workflowai/core/domain/run.py +++ b/workflowai/core/domain/run.py @@ -110,7 +110,7 @@ def format_output(self) -> str: # Add run information if available if self.cost_usd is not None: - output.append(f"Cost: $ {self.cost_usd}") + output.append(f"Cost: $ {self.cost_usd:.5f}") if self.duration_seconds is not None: output.append(f"Latency: {self.duration_seconds:.2f}s") diff --git a/workflowai/core/domain/run_test.py b/workflowai/core/domain/run_test.py index 34c65ce..7dc5b1e 100644 --- a/workflowai/core/domain/run_test.py +++ b/workflowai/core/domain/run_test.py @@ -67,7 +67,29 @@ def test_format_output() -> None: "message": "hello" } ================================================== -Cost: $ 0.001 +Cost: $ 0.00100 +Latency: 1.23s""" + + assert run.format_output() == expected + + +def test_format_output_very_low_cost() -> None: + run = Run[_TestOutput]( + id="test-id", + agent_id="agent-1", + schema_id=1, + output=_TestOutput(message="hello"), + duration_seconds=1.23, + cost_usd=4.97625e-05, + ) + + expected = """\nOutput: +================================================== +{ + "message": "hello" +} +================================================== +Cost: $ 0.00005 Latency: 1.23s""" assert run.format_output() == expected