Human-readable description of which config key produced *effective*.
(max_tokens: int, max_chars_direct: int, effective: int)
| 104 | |
| 105 | |
| 106 | def _limit_source_label(max_tokens: int, max_chars_direct: int, effective: int) -> str: |
| 107 | """Human-readable description of which config key produced *effective*.""" |
| 108 | token_chars = max_tokens * _CHARS_PER_TOKEN |
| 109 | both_active = token_chars > 0 and max_chars_direct > 0 |
| 110 | if both_active: |
| 111 | winner = "MAX_TOOL_RESPONSE_TOKENS" if token_chars <= max_chars_direct else "MAX_PROMPT_CHARS" |
| 112 | return f"{winner} ({effective} chars)" |
| 113 | if token_chars > 0: |
| 114 | return f"MAX_TOOL_RESPONSE_TOKENS ({max_tokens} tokens → {effective} chars)" |
| 115 | return f"MAX_PROMPT_CHARS ({effective} chars)" |
| 116 | |
| 117 | |
| 118 | def _apply_response_token_limit(tool_name: str, text: str) -> str: |
no outgoing calls