Try to parse a string as a number, return original if not possible.
(self, text: str)
| 1381 | return repr_str |
| 1382 | |
| 1383 | def _try_parse_number(self, text: str) -> Any: |
| 1384 | """Try to parse a string as a number, return original if not possible.""" |
| 1385 | if not text or not isinstance(text, str): |
| 1386 | return text |
| 1387 | |
| 1388 | text = text.strip() |
| 1389 | |
| 1390 | # Handle "None" string |
| 1391 | if text in ("None", "null", ""): |
| 1392 | return None |
| 1393 | |
| 1394 | # Try float (handles integers too) |
| 1395 | try: |
| 1396 | return float(text) |
| 1397 | except (ValueError, TypeError): |
| 1398 | pass |
| 1399 | |
| 1400 | return text |
| 1401 | |
| 1402 | def _format_tool_response(self, result: Any) -> str: |
| 1403 | """Format tool response for conversation history.""" |
no outgoing calls