Return the effective character budget from both config knobs. Picks the stricter (smallest) non-zero value. Returns 0 when both are zero, meaning no limit is active.
(max_tokens: int, max_chars_direct: int)
| 94 | |
| 95 | |
| 96 | def _effective_char_limit(max_tokens: int, max_chars_direct: int) -> int: |
| 97 | """Return the effective character budget from both config knobs. |
| 98 | |
| 99 | Picks the stricter (smallest) non-zero value. Returns 0 when both |
| 100 | are zero, meaning no limit is active. |
| 101 | """ |
| 102 | candidates = [c for c in (max_tokens * _CHARS_PER_TOKEN, max_chars_direct) if c > 0] |
| 103 | return min(candidates) if candidates else 0 |
| 104 | |
| 105 | |
| 106 | def _limit_source_label(max_tokens: int, max_chars_direct: int, effective: int) -> str: |
no outgoing calls