deprecated()
Return a decorator that deprecates a callable with explicit metadata. Use this helper when you can annotate a function, method, or property with @deprecated(…). It transparently forwards todeprecation.deprecated()
while filling in the SDK’s current version metadata unless custom values are
supplied.
maybe_truncate()
Truncate the middle of content if it exceeds the specified length. Keeps the head and tail of the content to preserve context at both ends. Optionally saves the full content to a file for later investigation.- Parameters:
content– The text content to potentially truncatetruncate_after– Maximum length before truncation. If None, no truncation occurstruncate_notice– Notice to insert in the middle when content is truncatedsave_dir– Working directory to save full content file intool_prefix– Prefix for the saved file (e.g., “bash”, “browser”, “editor”)
- Returns: Original content if under limit, or truncated content with head and tail preserved and reference to saved file if applicable
sanitize_openhands_mentions()
Sanitize @OpenHands mentions in text to prevent self-mention loops. This function inserts a zero-width joiner (ZWJ) after the @ symbol in @OpenHands mentions, making them non-clickable in GitHub comments while preserving readability. The original case of the mention is preserved.- Parameters:
text– The text to sanitize - Returns: Text with sanitized @OpenHands mentions (e.g., “@OpenHands” -> “@OpenHands”)
Examples
warn_deprecated()
Emit a deprecation warning for dynamic access to a legacy feature. Prefer this helper when a decorator is not practical—e.g. attribute accessors, data migrations, or other runtime paths that must conditionally warn. Provide explicit version metadata so the SDK reports consistent messages and upgrades todeprecation.UnsupportedWarning after the removal threshold.
