Skip to main content
sanitized_env() -> dict[str, str] source Return a copy of env with sanitized values. PyInstaller-based binaries rewrite LD_LIBRARY_PATH so their vendored libraries win. This function restores the original value so that subprocess will not use them.
env
Mapping[str, str] | None
None
deprecated() -> Callable[[_FuncT], _FuncT] source 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 to :func:deprecation.deprecated while filling in the SDK’s current version metadata unless custom values are supplied.
deprecated_in
str
required
None
removed_in
str | date | None
required
None
current_version
str | None
None
details
str
None
warn_deprecated() -> None source 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 to :class:deprecation.UnsupportedWarning after the removal threshold.
feature
str
required
None
deprecated_in
str
required
None
removed_in
str | date | None
required
None
current_version
str | None
None
details
str
None
stacklevel
int
None
sanitize_openhands_mentions() -> str source 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 str – The text to sanitize
Returns:
  • str Text with sanitized @OpenHands mentions (e.g., “@OpenHands” -> ”@‍OpenHands”)
Example:
>>> sanitize_openhands_mentions("Thanks @OpenHands for the help!")
'Thanks @\u200dOpenHands for the help!'
>>> sanitize_openhands_mentions("Check @openhands and @OPENHANDS")
'Check @\u200dopenhands and @\u200dOPENHANDS'
>>> sanitize_openhands_mentions("No mention here")
'No mention here'
text
str
required
None
maybe_truncate() -> str source 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 str – The text content to potentially truncate
  • truncate_after int | None – Maximum length before truncation. If None, no truncation occurs
  • truncate_notice str – Notice to insert in the middle when content is truncated
  • save_dir str | None – Working directory to save full content file in
  • tool_prefix str – Prefix for the saved file (e.g., “bash”, “browser”, “editor”)
Returns:
  • str Original content if under limit, or truncated content with head and tail
  • str preserved and reference to saved file if applicable
    content
    str
    required
    None
    truncate_after
    int | None
    None
    truncate_notice
    str
    None
    save_dir
    str | None
    None
    tool_prefix
    str
    None