hashOf static method
Computes the SHA-256 hash of payload.
Falls back to toString() when payload is not JSON-encodable, so the
oversized-result guard can never throw on an arbitrary tool payload
(FR-010 stability: an oversized result must not crash the tool call).
Implementation
static String hashOf(Object? payload) {
final String payloadStr;
if (payload is String) {
payloadStr = payload;
} else {
payloadStr = _jsonEncodeOrFallback(payload);
}
return crypto.sha256.convert(utf8.encode(payloadStr)).toString();
}