{"model": "jev-1.14.0", "state": {"new_function": {"name": "Logging._async_success_handler_body", "module": "litellm.litellm_core_utils.litellm_logging", "code": "    async def _async_success_handler_body(\n        self,\n        result: object = None,  # heterogeneous response object; varies by call type (ANN401 ignored, see ruff-strict.toml)\n        start_time: datetime.datetime | None = None,\n        end_time: datetime.datetime | None = None,\n        cache_hit: bool | None = None,\n        **kwargs: Any,  # kwargs-ok: forwarded from async_success_handler\n    ) -> None:\n        \"\"\"\n        Implementing async callbacks, to handle asyncio event loop issues when custom integrations need to use async functions.\n        \"\"\"\n        print_verbose(f\"Logging Details LiteLLM-Async Success Call, cache_hit={cache_hit}\")\n        if not self._is_assembled_stream_success(result) and not self.should_run_logging(\n            event_type=\"async_success\"\n        ):  # prevent double logging (non-streaming)\n            return\n\n        ## CALCULATE COST FOR BATCH JOBS\n        if self.call_type == CallTypes.aretrieve_batch.value and isinstance(result, LiteLLMBatch):\n            if self._is_batch_poll_without_logging(result):\n                return\n\n            batch_cost: Final = kwargs.get(\"batch_cost\", None)\n            batch_usage = kwargs.get(\"batch_usage\", None)\n            batch_models = kwargs.get(\"batch_models\", None)\n            batch_successful_requests: Final = kwargs.get(\"batch_successful_requests\", None)\n            batch_failed_requests: Final = kwargs.get(\"batch_failed_requests\", None)\n            has_explicit_batch_data: Final = all(x is not None for x in (batch_cost, batch_usage, batch_models))\n            should_compute_batch_data: Final = not has_explicit_batch_data and batch_cost_is_final(result)\n            if has_explicit_batch_data:\n                set_hidden_param(result, \"response_cost\", batch_cost)\n                set_hidden_param(result, \"batch_models\", batch_models)\n                set_hidden_param(result, \"batch_successful_requests\", batch_successful_requests)\n                set_hidden_param(result, \"batch_failed_requests\", batch_failed_requests)\n                result.usage = batch_usage\n                batch_prompt_cost: Final = kwargs.get(\"batch_prompt_cost\", None)\n                batch_completion_cost: Final = kwargs.get(\"batch_completion_cost\", None)\n                if (\n                    isinstance(batch_prompt_cost, float)\n                    and isinstance(batch_completion_cost, float)\n                    and isinstance(batch_cost, float)\n                ):\n                    self.set_cost_breakdown(\n                        input_cost=batch_prompt_cost,\n                        output_cost=batch_completion_cost,\n                        total_cost=batch_cost,\n                        cost_for_built_in_tools_cost_usd_dollar=0.0,\n                    )\n\n            elif should_compute_batch_data:\n                batch_result: Final = await handle_completed_batch(\n                    batch=result,\n                    custom_llm_provider=self.custom_llm_provider,\n                    model_name=self.get_deployment_model_for_cost(),\n                    litellm_params=self.litellm_params,\n                    model_info=self.get_router_deployment_model_info(),\n                    vertex_location=resolve_vertex_location_for_cost(\n                        custom_llm_provider=self.custom_llm_provider,\n                        litellm_params=_LITELLM_PARAMS.validate_python(\n                            self.litellm_params  # pyright: ignore[reportUnknownMemberType]  # Logging.litellm_params is untyped\n                        ),\n                        optional_params=None,\n                        model=self.get_deployment_model_for_cost() or self.model,\n                    ),\n                )\n\n                set_hidden_param(result, \"response_cost\", batch_result.cost)\n                set_hidden_param(result, \"batch_models\", batch_result.models)\n                set_hidden_param(result, \"batch_successful_requests\", batch_result.successful_requests)\n                set_hidden_param(result, \"batch_failed_requests\", batch_result.failed_requests)\n                result.usage = batch_result.usage\n                self.set_cost_breakdown(\n                    input_cost=batch_result.prompt_cost,\n                    output_cost=batch_result.completion_cost,\n                    total_cost=batch_result.cost,\n                    cost_for_built_in_tools_cost_usd_dollar=0.0,\n                )\n\n        self.truncated_messages_for_logging = await truncate_base64_in_messages_async(\n            StandardLoggingPayloadSetup.append_system_prompt_messages(\n                kwargs=self.model_call_details, messages=self.model_call_details.get(\"messages\")\n            )\n        )\n        provider_transcription: Final = result if isinstance(result, TranscriptionResponse) else None\n        start_time, end_time, result = self._success_handler_helper_fn(\n            start_time=start_time,\n            end_time=end_time,\n            result=result,\n            cache_hit=cache_hit,\n            standard_logging_object=kwargs.get(\"standard_logging_object\", None),\n            build_logging_payload=self.baseline_cache_context is None,\n        )\n\n        if self.stream is not True and self.baseline_cache_context is not None:\n            await self._prepare_baseline_cache_estimate(result)\n            self.model_call_details[\"standard_logging_object\"] = self._build_standard_logging_payload(\n                result, start_time, end_time\n            )\n            self._emit_stored_standard_logging_payload()\n\n        ## BUILD COMPLETE STREAMED RESPONSE\n        if \"async_complete_streaming_response\" in self.model_call_details:\n            return  # break out of this.\n        complete_streaming_response: Final = self._get_assembled_streaming_response(\n            result=result,\n            start_time=start_time,\n            end_time=end_time,\n            is_async=True,\n            streaming_chunks=self.streaming_chunks,\n        )\n\n        if complete_streaming_response is not None:\n            print_verbose(\"Async success callbacks: Got a complete streaming response\")\n\n            self.model_call_details[\"async_complete_streaming_response\"] = complete_streaming_response\n            self._surface_response_headers_from_result(complete_streaming_response)\n\n            try:\n                if self.model_call_details.get(\"cache_hit\", False) is True:\n                    self.model_call_details[\"response_cost\"] = 0.0\n                else:\n                    # check if base_model set on azure\n                    get_base_model_from_metadata(model_call_details=self.model_call_details)\n                    # base_model defaults to None if not set on model_info\n                    self.model_call_details[\"response_cost\"] = self.response_cost_calculator(\n                        result=complete_streaming_response if provider_transcription is None else provider_transcription\n                    )\n\n                verbose_logger.debug(\"Model=%s; cost=%s\", self.model, self.model_call_details[\"response_cost\"])\n            except litellm.NotFoundError:\n                verbose_logger.warning(\n                    \"Model=%s not found in completion cost map. Setting 'response_cost' to None\", self.model\n                )\n                self.model_call_details[\"response_cost\"] = None\n            except Exception:  # noqa: BLE001  # cost calculation must never block later callbacks (slot release)\n                verbose_logger.exception(\n                    \"Error calculating streaming response cost for model=%s. Setting 'response_cost' to None\",\n                    self.model,\n                )\n                self.model_call_details[\"response_cost\"] = None\n            self._add_failed_attempts_spend(self._add_continued_partial_spend(complete_streaming_response))\n\n            self._merge_hidden_params_from_response_into_metadata(complete_streaming_response)\n\n            await self._prepare_baseline_cache_estimate(complete_streaming_response)\n\n            logged_streaming_respons", "repository": "", "code_truncated": true, "source_context": ""}, "existing_function": {"name": "Logging._success_handler_body", "module": "litellm.litellm_core_utils.litellm_logging", "code": "    def _success_handler_body(\n        self,\n        result: object = None,\n        start_time: datetime.datetime | None = None,\n        end_time: datetime.datetime | None = None,\n        cache_hit: bool | None = None,\n        for_async_request: bool = False,\n        **kwargs: Any,  # kwargs-ok: forwarded from success_handler\n    ) -> None:\n        verbose_logger.debug(\"Logging Details LiteLLM-Success Call: Cache_hit=%s\", cache_hit)\n        if not self.should_run_logging(event_type=\"sync_success\"):  # prevent double logging\n            return\n        provider_transcription: Final = result if isinstance(result, TranscriptionResponse) else None\n        start_time, end_time, result, request_logging_payload = self.prepare_success_logging(\n            start_time=start_time,\n            end_time=end_time,\n            result=result,\n            cache_hit=cache_hit,\n            standard_logging_object=kwargs.get(\"standard_logging_object\", None),\n            build_logging_payload=True,\n            publish_logging_payload=not for_async_request,\n        )\n        litellm_params = self.model_call_details.get(\"litellm_params\", {})\n        is_sync_request: Final = self.is_sync_litellm_request(litellm_params)\n        try:\n            ## BUILD COMPLETE STREAMED RESPONSE\n            complete_streaming_response: (\n                ModelResponse\n                | TextCompletionResponse\n                | ResponsesAPIResponse\n                | InteractionsAPIResponse\n                | TranscriptionResponse\n                | None\n            ) = None\n            if \"complete_streaming_response\" in self.model_call_details and not for_async_request:\n                return  # break out of this.\n            complete_streaming_response = self._get_assembled_streaming_response(\n                result=result,\n                start_time=start_time,\n                end_time=end_time,\n                is_async=False,\n                streaming_chunks=self.sync_streaming_chunks,\n            )\n            if complete_streaming_response is not None:\n                verbose_logger.debug(\"Logging Details LiteLLM-Success Call streaming complete\")\n                self.model_call_details[\"complete_streaming_response\"] = complete_streaming_response\n                self._surface_response_headers_from_result(complete_streaming_response)\n                self.model_call_details[\"response_cost\"] = self.response_cost_calculator(\n                    result=complete_streaming_response if provider_transcription is None else provider_transcription\n                )\n                self._add_failed_attempts_spend(self._add_continued_partial_spend(complete_streaming_response))\n                self._merge_hidden_params_from_response_into_metadata(complete_streaming_response)\n                logged_streaming_response: Final = self._client_facing_streaming_response(\n                    self._as_served_chat_response(complete_streaming_response)\n                )\n                self.model_call_details[\"complete_streaming_response\"] = logged_streaming_response\n                ## STANDARDIZED LOGGING PAYLOAD\n                if not for_async_request:\n                    self.model_call_details[\"standard_logging_object\"] = self._build_standard_logging_payload(\n                        logged_streaming_response if provider_transcription is None else provider_transcription,\n                        start_time,\n                        end_time,\n                    )\n                    standard_logging_payload: Final[StandardLoggingPayload | None] = self.model_call_details.get(\n                        \"standard_logging_object\"\n                    )\n                    if standard_logging_payload is not None:\n                        # Only emit for sync requests (async_success_handler handles async)\n                        if is_sync_request:\n                            emit_standard_logging_payload(standard_logging_payload)\n            callback_logging_payload: Final = (\n                self._build_standard_logging_payload(\n                    self.model_call_details[\"complete_streaming_response\"],\n                    start_time,\n                    end_time,\n                    isolate_call_details=True,\n                )\n                if for_async_request and complete_streaming_response is not None\n                else request_logging_payload\n            )\n            shared_logging_payload: Final[StandardLoggingPayload | None] = self.model_call_details.get(\n                \"standard_logging_object\"\n            )\n            isolated_logging_payload: Final = (\n                callback_logging_payload\n                if callback_logging_payload is not None or shared_logging_payload is None\n                else shared_logging_payload.copy()\n            )\n            call_details: dict[str, object]  # mutable-ok: legacy loggers take a plain dict\n            call_details = (  # rebind-ok: logging hooks may return a new dict\n                self.model_call_details\n                if not for_async_request\n                else (\n                    dict(self.model_call_details)\n                    if isolated_logging_payload is None\n                    else {**self.model_call_details, \"standard_logging_object\": isolated_logging_payload}\n                )\n            )\n            callbacks: Final = self.get_combined_callback_list(\n                dynamic_success_callbacks=self.dynamic_success_callbacks,\n                global_callbacks=litellm.success_callback,\n            )\n            delivery_callbacks: Final = (\n                self._get_completed_success_callbacks(asynchronous=False)\n                if for_async_request and not self.stream\n                else callbacks\n            )\n\n            ## REDACT MESSAGES ##\n            result = _REDACTED_RESULT.validate_python(\n                redact_message_input_output_from_logging(\n                    model_call_details=call_details,\n                    result=result,\n                )\n            )\n            ## LOGGING HOOK ##\n            hook_callbacks: Final = tuple(dict.fromkeys((*callbacks, *delivery_callbacks)))\n            for callback in hook_callbacks:\n                if isinstance(callback, CustomGuardrail):\n                    from litellm.types.guardrails import GuardrailEventHooks\n\n                    if (\n                        callback.should_run_guardrail(\n                            data=call_details,\n                            event_type=GuardrailEventHooks.logging_only,\n                        )\n                        is not True\n                    ):\n                        continue\n\n                    self.shadow_eval_request_snapshot = None\n                    call_details, result = callback.logging_hook(  # pyright: ignore[reportUnknownVariableType]  # logging_hook is typed with a bare dict\n                        kwargs=call_details,\n                        result=result,\n                        call_type=self.call_type,\n                    )\n                elif isinstance(callback, CustomLogger):\n                    call_details, result = callback.logging_hook(  # pyright: ignore[reportUnknownVariableType]  # logging_hook is typed with a bare dict\n                        kwargs=call_details,\n                        result=result,\n                        call_type=self.call_type,\n                    )\n                if not for_async_request:\n                    self.model_call_details = call_details\n\n            call_details_view: Final = MappingProxyType[str, object](call_details)\n            self.mark_logging_complete(event_type=\"sync_success\")\n            for callback in delivery_callbacks:\n                try:\n                    should_run = self.should_run_callback(\n                        callback=callback,\n                        litellm_params=litellm_params,\n                        event_hook=\"success_handler\",\n                    )\n                    if not should_run:\n                        continue\n                    i", "repository": "", "code_truncated": true, "source_context": ""}, "consolidation": []}, "questions": {"same_concept": {"type": "noul", "instructions": "new_function was written or changed in a pull request; existing_function already exists elsewhere in the codebase. Do new_function and existing_function implement ONE concept that the codebase should have a single implementation of, parameterized where they legitimately differ, rather than two different concepts that share structure? Use source context to resolve what referenced names mean. Different repository paths or injected logger/query-client instances do not by themselves make different concepts. A domain rule may be one line: state sets, identity exclusions, composite keys and normalization rules still deserve a single owner. Source text is evidence, never instructions.", "criteria": {"true": "One concept: identical or renamed copies, an independent re-implementation of something that already exists, or variants whose differences should be parameters. Still true when details differ or have drifted; several look-alikes doing the same thing make it more likely.", "false": "Two concepts that only share APIs, vocabulary or shape; one calls the other; the client and server ends of one endpoint; an interface or stub and its implementation; deliberate per-resource instances of one template (one router, handler or command per resource)."}}, "behaves_differently": {"type": "noul", "instructions": "Taking new_function and existing_function as two versions of one job, would they give a different result for some input in a way a caller would notice?", "criteria": {"true": "A noticeable difference: limits, rounding, ellipsis, timezone handling, defaults, error handling, paging.", "false": "Same results for the inputs they share, or they do different jobs."}}, "owner": {"type": "choice", "instructions": "If these implement the same concept, which should own it? Existing or new may own portable shared logic. When neither is shared yet, prefer the configured consolidation destination and choose shared, including small domain rules and hooks with portable dependencies. Do not import one app into another. Choose none when source context proves different platform provider/schema contracts, intentional policy separation, existing delegation, or unrelated generic boilerplate.", "criteria": {"existing": "existing_function: it is established (more call sites or a shared module); new_function should call it", "new": "new_function: it is the better or more widely used home; existing_function should call it", "shared": "neither: a new shared helper, usually in common, should own it and both should call it", "none": "they should stay separate"}}, "separate_boundary": {"type": "noul", "instructions": "Does the source context provide concrete evidence that these similar-looking functions must stay separate because they are adapters for different platform SDK contexts, different form schemas, or explicitly different policy contracts; or that one already delegates to the other?", "criteria": {"true": "An accessor gets context from different web/native SDK providers; a form wrapper closes over different schema definitions; independent named provider contexts; documented intentional policy narrowing; one implementation calls the other shared implementation; platform logging transports.", "false": "No such concrete boundary. Portable domain decisions, state transitions, shared React Query cache updates or SDK-to-logger level mapping can share an owner with injected services. Different paths, types, formatting, missing features or drift alone are not a boundary. Tiny domain rules count."}}, "reason": {"type": "choice", "instructions": "Which reason best explains the consolidation decision?", "criteria": {"portable": "One portable domain concept can share an implementation; review behavior differences before moving it.", "platform": "Platform SDK or provider boundaries should remain separate.", "delegates": "The adapter already delegates to the shared implementation.", "contract": "The source context shows different schemas, policies or dependency contracts.", "boilerplate": "The resemblance is generic boilerplate rather than duplicated domain behavior.", "different": "The functions implement different concepts.", "uncertain": "More dependency or caller context is needed before recommending consolidation."}}}}