def _parse_response(self, raw_text: str, request) -> ToolOutput:
        """
        Parse the raw response and determine if it's a clarification request or follow-up.

        Some tools may return JSON indicating they need more information or want to
        continue the conversation. This method detects such responses and formats them.

        Args:
            raw_text: The raw text response from the model
            request: The original request for context

        Returns:
            ToolOutput: Standardized output object
        """
        # Check for follow-up questions in JSON blocks at the end of the response
        follow_up_question = self._extract_follow_up_question(raw_text)
        logger = logging.getLogger(f"tools.{self.name}")

        if follow_up_question:
            logger.debug(
                f"Found follow-up question in {self.name} response: {follow_up_question.get('follow_up_question', 'N/A')}"
            )
        else:
            logger.debug(f"No follow-up question found in {self.name} response")

        try:
            # Try to parse as JSON to check for clarification requests
            potential_json = json.loads(raw_text.strip())

            if isinstance(potential_json, dict) and potential_json.get("status") == "requires_clarification":
                # Validate the clarification request structure
                clarification = ClarificationRequest(**potential_json)
                return ToolOutput(
                    status="requires_clarification",
                    content=clarification.model_dump_json(),
                    content_type="json",
                    metadata={
                        "original_request": (request.model_dump() if hasattr(request, "model_dump") else str(request))
                    },
                )

        except (json.JSONDecodeError, ValueError, TypeError):
            # Not a JSON clarification request, treat as normal response
            pass

        # Normal text response - format using tool-specific formatting
        formatted_content = self.format_response(raw_text, request)

        # If we found a follow-up question, prepare the threading response
        if follow_up_question:
            return self._create_follow_up_response(formatted_content, follow_up_question, request)

        # Check if we should offer Claude a continuation opportunity
        continuation_offer = self._check_continuation_opportunity(request)

        if continuation_offer:
            logger.debug(
                f"Creating continuation offer for {self.name} with {continuation_offer['remaining_turns']} turns remaining"
            )
            return self._create_continuation_offer_response(formatted_content, continuation_offer, request)
        else:
            logger.debug(f"No continuation offer created for {self.name}")

        # If this is a threaded conversation (has continuation_id), save the response
        continuation_id = getattr(request, "continuation_id", None)
        if continuation_id:
            request_files = getattr(request, "files", []) or []
            success = add_turn(
                continuation_id,
                "assistant",
                formatted_content,
                files=request_files,
                tool_name=self.name,
            )
            if not success:
                logging.warning(f"Failed to add turn to thread {continuation_id} for {self.name}")

        # Determine content type based on the formatted content
        content_type = (
            "markdown" if any(marker in formatted_content for marker in ["##", "**", "`", "- ", "1. "]) else "text"
        )

        return ToolOutput(
            status="success",
            content=formatted_content,
            content_type=content_type,
            metadata={"tool_name": self.name},
        )

        Parse the raw response and determine if it's a clarification request or follow-up.

        Some tools may return JSON indicating they need more information or want to
        continue the conversation. This method detects such responses and formats them.

        Args:
            raw_text: The raw text response from the model
            request: The original request for context

        Returns:
            ToolOutput: Standardized output object
        
tools/base.py