Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

532 B
Raw Blame
"""Shared shaping of error details for task run failure telemetry."""

ERROR_MESSAGE_TELEMETRY_LIMIT = 500


def truncate_error_message(message: str | None, limit: int = ERROR_MESSAGE_TELEMETRY_LIMIT) -> str:
    """Truncate an error message keeping its tail.

    Agent and wizard failures bury the root cause at the end of their output
    (boilerplate preamble first, actual error last), so head truncation hides it.
    """
    if not message:
        return ""
    return message if len(message) <= limit else message[-limit:]