def get_customer_profile(tool_context: ToolContext) -> dict: """Retrieves current customer profile. Args: tool_context: Provided by ADK. Returns: dict: Profile details or error. """ try: profile_key = "user:customer_profile" profile = tool_context.state.get(profile_key, {}) if not profile: return { "status": "success", "message": "No customer profile found.", "profile": {} } clean_profile = {k: v for k, v in profile.items() if k != "update_history"} return { "status": "success", "message": "Customer profile retrieved.", "profile": clean_profile, "last_updated": profile.get("update_history", [{}])[-1].get("timestamp", "Never") } except Exception as e: return { "status": "error", "error_message": f"Failed to retrieve profile: {str(e)}" } __ __