Create an AppSDK-compatible error payload.
(error_text: str, status: int | None = None)
| 205 | |
| 206 | |
| 207 | def build_appsdk_error_response(error_text: str, status: int | None = None) -> dict[str, Any]: |
| 208 | """Create an AppSDK-compatible error payload.""" |
| 209 | structured_content: dict[str, Any] = { |
| 210 | "error": { |
| 211 | "message": error_text, |
| 212 | } |
| 213 | } |
| 214 | if status is not None: |
| 215 | structured_content["error"]["status"] = status |
| 216 | |
| 217 | return { |
| 218 | "structuredContent": structured_content, |
| 219 | "content": [ |
| 220 | {"type": "text", "text": f"Error: {error_text}"}, |
| 221 | ], |
| 222 | } |
| 223 | def _stable_repr(value: Any) -> str: |
| 224 | """Generate a hashable representation for potentially nested data structures.""" |
| 225 | try: |
no outgoing calls