Skip to main content

format_percent

Function
This function is defined in the context module.
Smart percentage formatting for context utilization display.
  • For values < 0.1%: shows “<0.1%”
  • For values < 1%: shows 2 decimal places (e.g., “0.02%”)
  • For values >= 1%: shows 1 decimal place (e.g., “5.3%“)

Signature

def format_percent(value: float) -> str

Parameters

value
float
required
A ratio (0.0 to 1.0+), NOT already multiplied by 100

Returns

Returns
str
Formatted percentage string